代码是这样的,在data中定义了一个名为AnimatorChoices的属性并设置为false
data() {
return {
AnimatorChoices: false
}
},
在methods中打印
methods: {
upOptions() {
console.log(this.AnimatorChoices) //这里输出false
onscroll = function () {
let height = document.body.scrollTop || document.documentElement.scrollTop;
if (height > 80) {
console.log(this.AnimatorChoices) //这里输出为什么为undefined
this.AnimatorChoices = true;
console.log(this.AnimatorChoices)
}
}
}
},
方法在created声明周期函数中调用
created() {
this.upOptions()
}
为什么会输出undefined