bind
bind方法生成了一个新的函数,称为绑定函数,传入bind方法的第一个參数作为这个绑定函数的this对象,传入bind的第二个參数连同后面调用绑定函数时传入的參数依照先后顺序(传入bind的在前)构成绑定函数的參数。
onClick:function(picker) {
const date1 = new Date();
const start = new Date().setMonth(0-12);
const end = date1.setMonth(0-1);
picker.$emit('pick', start);
this.searchs.open_date[0]=start;
this.searchs.open_date[1]=end;
}.bind(this)
将 全局的this 传入,使得
this.searchs.open_date[0],this.searchs.open_date[1]可以被正确赋值
越努力越幸运

浙公网安备 33010602011771号