Advertisement

vue 动态渲染数据 this.$nextTick & swiper组件

阅读量:
复制代码
    在 mounted 钩子里,不能根据数据改变而改变
    如果放在 updated 钩子里,随便一个数据发生改变,都会重新生成补丁对象
    但每次都实例化,这样是肯定不行的
    所以有了 $nextTick
    
    
      
      
      
      
    

nextTick意味着在所有真实DOM渲染完成之后才会执行

this.$nextTick(() => { })

复制代码
    <template>
      <div class="swiper-container">
    <input type="text" v-model ="num">
      <div class="swiper-wrapper">
          <div class="swiper-slide"
            v-for = "item in banners"
            :key = "item.id"
          >
            <img :src = "item.img" alt="">
          </div>
      </div>
      <!-- 如果需要分页器 -->
      <div class="swiper-pagin

全部评论 (0)

还没有任何评论哟~