nextTick和setTimeout对比 (代码编译 --- uni-app小程序)
例1
this.$nextTick(()=>{ console.log("2"); this.$nextTick(function(){ console.log("4"); setTimeout(()=>{ console.log("7") },0) }) setTimeout(()=>{ console.log("6") },0) }) this.$nextTick(()=>{ console.log("3") _this.$nextTick(()=>{ console.log("1"); setTimeout(()=>{ console.log("5") },0) }) })
return;
例一 结果
例2
this.$nextTick(()=>{ console.log("2"); setTimeout(()=>{ console.log("6") },0) this.$nextTick(function(){ setTimeout(()=>{ console.log("7") },0) console.log("4"); }) }) _this.$nextTick(()=>{ _this.$nextTick(()=>{ console.log("1"); setTimeout(()=>{ console.log("5") },0) }) console.log("3") })
return;
例2 结果