Vue this.$nextTick() 之后再执行,导致渲染不准确跪求!

问题
this.$nextTick(()=>{
this.$refs.multipleTable.toggleAllSelection()
this.isChecked=false
})
注意:this.$refs.multipleTable.toggleAllSelection()必须放在this.$nextTick()里面执行才能生效
如上所示我希望先执行this.$refs.multipleTable.toggleAllSelection(),再this.isChecked=false,但是经过测试发现this.isChecked=false总是在前执行导致页面渲染不正确
弱鸡解决法
this.$nextTick(()=>{
this.$refs.multipleTable.toggleAllSelection()
setTimeout(()=>{
this.isChecked=false
},100);
})
这样可以解决这个问题,但是总感觉不太好
尝试过封装asyncawit但是无效如下:
constnextTickAsync=()=>{
returnnewPromise((resolve,reject)=>{
this.$nextTick(()=>{
this.$refs.multipleTable.toggleAllSelection();
resolve(true)
})
})
}
constisCheckedAsycn=()=>{
returnnewPromise((resolve,reject)=>{
this.$nextTick(()=>{
this.isChecked=false
resolve(true)
})
})
}
(async()=>{
awaitnextTickAsync()
awaitisCheckedAsycn()
})()
求问解决方法?
如何先执行完this.$nextTick()在执行后续的this.isChecked=false
拉丁的传说
浏览 910回答 2
2回答

PIPIONE

this.$refs.multipleTable.toggleAllSelection()this.$nextTick(()=>{this.isChecked=false})

慕田峪4524236

注意:this.$refs.multipleTable.toggleAllSelection()必须放在this.$nextTick()里面执行才能生效
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript