<>前言:

<>这里分享3.0和2.0 的方法对比,

<>nextTick 是将回调推迟到下一个 DOM 更新周期之后执行。在更改了一些数据以等待 DOM 更新后立即使用它

<>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 } }
<>页面上:
<a-boo v-if="otherParam.showA"></a-boo>
<>vue2.0
this.abc = false this.$nextTick(() => { //你要执行的方法 this.abc = true })

技术
今日推荐
PPT
阅读数 135
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信