看了很多教程,都说process.nextTick是最先执行的,但我自己跑的时候却是最后执行的。vue的nextTick按理说优先使用promise,但我跑的时候也是比较后执行的。watch的执行又应该属于哪一种任务呢,Object.observe吗?export default {
data() { return {
a = false
}
}
watch: {
a() { console.log("watch")
}
}
methods: {
myprint() { this.a = true
setTimeout(() => console.log("settimeout"), 0) this.$nextTick(() => console.log("vue nexttick"))
process.nextTick(() => console.log("process.nexttick"))
Promise.resolve().then(() => console.log("promise")) console.log("start")
}
}打印出来结果为:startpromise
watch
vue nexttick
settimeout
process.nexttick
1 回答
- 1 回答
- 0 关注
- 1765 浏览
添加回答
举报
0/150
提交
取消