vue3.0刷新当前组件nextTick

前言:

       在vue2.0我们想刷新一个组件的话是可以在data里面定义一个变量,然后methods里面直接this.$nextTick直接调用这个函数来操作的,在vue3.0中的setup他的用法是不一样的

在setup中的用法:

1、引入reactivenextTick 


import { reactive,nextTick  } from 'vue'

2、setup中定义变量

setup (props, ctx) {
 //定义变量
 let table = reactive({
      showTable: true
    })
 //使用刷新
 table.showTable = false
 nextTick(()=>{
    //写入操作
     table.showTable = true
  })
}

猜你喜欢

转载自blog.csdn.net/qq_41619796/article/details/114533877