methods: { A: function() { setInterval(function(){ this.B(); },500) }, B: function() { console.log('func B') }}这样写会报错,怎么实现这样的效果呢?
1 回答
www说
TA贡献1775条经验 获得超8个赞
可以使用箭头函数
methods: { A: function() {
setInterval(() => {
this.B();
}, 500)
}, B: function() { console.log('func B')
}
}或者
methods: { A: function() {
setInterval(this.B, 500)
}, B: function() { console.log('func B')
}
}添加回答
举报
0/150
提交
取消
