Vue异步刷新
在学习Vue异步刷新之前,必须要了解Vue.nextTick()的用法。接下来先学习Vue.nextTick()
一、Vue.nextTick
1.什么是Vue.nextTick()
定义:在下次DOM 更新循环结束之后执行延迟回调。获取更新后的DOM的Vue方法。放在Vue.nextTick()回调函数中的执行的应该是会对DOM进行操作的 js代码。
理解:nextTick(),是将回调函数延迟在下一次dom更新数据后调用。
<template>
<div class="hello">
<button id="firstBtn" @click="testClick()" ref="aa">{
{testMsg}}</button>
</div>
</template>
<script type="module">
export default {
name: 'hello',
data()