摘要: 1.组件为什么是一个函数 组件中的data写成一个函数,数据以函数返回值形式定义,这样每复用一次组件,就会返回一份新的data,类似于给每个组件实例创建一个私有的数据空间,让各个组件实例维护各自的数据。而单纯的写成对象形式,就使得所有组件实例共用了一份data,就会造成一个变了全都会变的结果。 2. 阅读全文
posted @ 2021-10-31 23:36 yongerbingxuan 阅读(35) 评论(0) 推荐(0)
摘要: //jQuery $(function () { $("button").click(function () { // console.log(1); $.ajax({ url: "http://127.0.0.1:3000/", method: "GET", success(data) { con 阅读全文
posted @ 2021-10-26 19:59 yongerbingxuan 阅读(24) 评论(0) 推荐(0)
摘要: // 类似于将foo()中yield 3; yield 4; 添加到bar() // 只输出调用的函数下的return值 function* foo() { yield 3; yield 4; return "pubg";//在bar()的调用下,不会输出此值 } function* bar() { 阅读全文
posted @ 2021-10-25 19:21 yongerbingxuan 阅读(27) 评论(0) 推荐(0)
摘要: let obj = { time: "8.8", doing: "listen to music", who: "sbluo", length: 3, [Symbol.iterator]() { let _this = this; let index = 0; let arr = []; for ( 阅读全文
posted @ 2021-10-25 19:03 yongerbingxuan 阅读(41) 评论(0) 推荐(0)
摘要: //按位非(NOT) function NOT() { let num1 = 25; let num2 = ~num1;//-26 类似于 -n-1 console.log(num2); } //按位与(AND) //把左右两边的数字转化为二进制,然后每一位分别进行比较,如果相等就为相等的数(0|| 阅读全文
posted @ 2021-10-24 15:43 yongerbingxuan 阅读(67) 评论(0) 推荐(0)
摘要: let arr1=[1,2,3,4]; let arr2=[5,6,7,8]; //push()元素直接添加到末尾,可以添加多个元素 //pop()删除数组末尾第一个元素 //unshift()在数组开头插入值,可以添加多个元素 //shift()在数组开头删除第一个值 //splice() // 阅读全文
posted @ 2021-10-24 15:00 yongerbingxuan 阅读(25) 评论(0) 推荐(0)
摘要: //match() var str = "中国移动10086,中国联通10010,中国电信10000"; let arr = str.match(/\d{5}/g)//10086 10010 10000 //replace() let str="盈十里煌绸 交 错" str.replace(/\s/ 阅读全文
posted @ 2021-10-23 23:35 yongerbingxuan 阅读(21) 评论(0) 推荐(0)
摘要: function num(){ var num=10; num++; console.log(num); } num();//11 num();//11 num();//11 function f1(){ var num=10; return function(){ num++; return nu 阅读全文
posted @ 2021-10-23 22:42 yongerbingxuan 阅读(30) 评论(0) 推荐(0)
摘要: //call继承主要是继承构造函数中的属性 function Person(age, sex) { this.age = age; this.sex = sex; } Person.prototype.Sleep = function () { console.log("睡觉"); } Person 阅读全文
posted @ 2021-10-23 19:12 yongerbingxuan 阅读(108) 评论(0) 推荐(0)
摘要: //原型继承主要是继承构造函数中的原型(改变原型指向) 在子类构造函数与父类构造函数中有相同的属性时父类无法覆盖子类 function Person(age,sex){ this.age=age; this.sex=sex; } Person.prototype.Sleep=function(){ 阅读全文
posted @ 2021-10-23 19:03 yongerbingxuan 阅读(37) 评论(0) 推荐(0)