javascript - VUE里面 watch log出来的this,与mounted log出来的this 不一样! 诡异?
本文介绍了javascript - VUE里面 watch log出来的this,与mounted log出来的this 不一样! 诡异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
watch:{
Applist:()=>{
console.log("Applist改变");
var _self = this;
console.log(_self);
var scroll_area = document.getElementById('scroll_area');
setTimeout(()=>{
console.log(_self);
_self.scrollbar(scroll_area);
},100)
}
},
mounted: function(){
let _self=this;
console.log("log self");
console.log(_self);
let scroll_area = document.getElementById('scroll_area');
_self.getAppList();
setTimeout(()=>{
_self.scrollbar(scroll_area);
},100)
}
解决方案
其实官方文档有写,都不能用箭头函数的
这篇关于javascript - VUE里面 watch log出来的this,与mounted log出来的this 不一样! 诡异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文