pickerOptionsState() {//state==true 是不能选的
let _this = this
return {
disabledDate(time) {
console.warn(this)
let state = null
if(_this.ruleForm.expectedDeliveryTime == null) {
state = false
} else {
state = time.getTime() > new Date(_this.ruleForm.expectedDeliveryTime)
}
console.warn(this)
return state
}
}
},
这边 首先 _this = this 这边的this 可以取到 是全局的this 然后 return 里面的函数的this 没有
return 返回的是对象
https://blog.csdn.net/sunhl951/article/details/80023347
this是Javascript语言的一个关键字,它代表函数运行时,自动生成的一个内部对象,在每个 function 中自动根据作用域(scope) 确定, 指向的是此次调用者。
在非严格模式下,由于this必须是一个对象,所以就默认为指向全局对象window。在严格模式下,上面的代码则会出现不同的结果
var message = { content: "I'm a message!", showContent: function() { console.log(this.content); } }; message.showContent(); // I'm a message!
这边是 指向 message 对象
bind方法和call,apply的区别在于,bind() 之后函数并没有执行,可以传给其他函数,在某个适当的时机再调用。