vue3.0中使用nextTick
vue3.0
1、引入
import { nextTick } from 'vue'
2、具体使用,配合异步
setup() { const message = ref('Hello!') const changeMessage = async newMessage => { message.value = newMessage await nextTick() console.log('Now DOM is updated') } }
3、具体使用,普通
方法里:
setup () { let otherParam = reactive({ showA:false }) nextTick(()=>{ otherParam.showA = true }) return { otherParam } }
页面上:
vue2.0
this.abc = false this.$nextTick(() => { //你要执行的方法 this.abc = true })