
JS
陪着月亮
前端开发,不断学习中...
展开
-
【ajax】withCredentials
默认值:false。在获取同域资源时设置 withCredentials 没有影响。true:在跨域请求时,会携带用户凭证false:在跨域请求时,不会携带用户凭证;返回的 response 里也会忽略 cookie。原创 2023-10-18 09:52:05 · 900 阅读 · 0 评论 -
【IE】:js禁止Backspace键使浏览器后退
IE浏览器,非输入框处按backspace键, 浏览器默认回退。其他浏览器,像chrome, 浏览器本身禁用backspace回退功能。全局使用:app.vue中:mounted() { document.onkeypress = this.banBackSpace; document.onkeydown = this.banBackSpace;},methods: { banBackSpace(e) { function stopI原创 2020-10-19 10:55:21 · 634 阅读 · 0 评论 -
【js】生成树状结构
获取到的data数组,包含所有树状结构的数据, data里的数据项是对象。对象中有pId, 为父级的id。通过pId找父级元素。function setTree(data) { data.forEach(function (item) { elete item.children;// 删除 所有 children,以防止多次调用 }); // 将数据存储为 以 id 为 KEY 的 map 索引数据列 var map = {}; d原创 2020-09-01 13:43:30 · 395 阅读 · 0 评论 -
【js】this的指向
① 在普通函数中,this指向window② 在构造函数中,this指向创建的对象③ 在方法声明中,this指向调用者④ 在定时器中, this指向window⑤ 在事件中,this 指向事件源一、普通函数中thisthis指向window;function test() { console.log(this);}test();二、构造函数中thisthis指向构造函数创建的对象。//构造函数function F() { this.a = 1; cons原创 2021-07-15 10:59:06 · 125 阅读 · 0 评论 -
【js】call、apply、bind
原创 2023-06-15 14:11:09 · 74 阅读 · 0 评论