
vue项目开发中如何调用this.$nextTick()方法,下面web建站小编给大家详细介绍一下实现方法!
具体代码如下:
<template>
<div>
<button @click=clickButton()" ref="test">{{testMsg}}</button>
</div>
</template>
<script>
export default {
data () {
return {
testMsg:"初始赋值",
}
},
methods:{
clickButton:function(){
let that=this;
that.testMsg="修改后的值";
that.$nextTick(function(){ //使用$nextTick()方法可以dom数据更新后延迟执行
console.log('修改完成后输出:'that.$refs.test.innerText);
});
}
}
}
</script>
定时器setTimeout和vue函数$nextTick有什么区别
上面是“vue项目中如何调用this.$nextTick()方法”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3077.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

一款专为编程和命令行界面设计的开源等宽字体——Maple Mono