解決vue使用vant輪播組件swipe + flex時文字抖動問題

原抖動效果

改後效果

解決方法

在外層容器的css裡加上:transform: translateZ(0);

部分頁面代碼

<van-swipe-item v-for="(item,index) in meetingList" :key="index">
   <div class="d-meet-top">
     <div>
      <van-icon name="clock" class="v-icon" color="#AEAEB0"/>
      <span class="gray s-text">今天</span>
      <span class="gray" style="color:#111111;font-weight:bold;letter-spacing: -1px;">
        {{item.startTime}}
        <span class="gray" style="margin:0 .5rem;">—</span>
        {{item.endTime}}
      </span>
     </div>
      <div class="d-status green">
       <span>進行中</span>
     </div>
   </div>
   <div class="d-meet-top">
     <div>
      <van-icon name="location" class="v-icon" color="#AEAEB0"/>
      <span class="gray s-text">{{item.location}}</span>
     </div>
     <div>
      <span class="gray s-text" style="margin-left:0;">參會人</span>
      <span class="s-name" v-for="(data,index) in item.person" :key="index"> {{data.substring(0,1)}}</span>
      <van-icon v-if="item.person.length>3 || true" name="ellipsis" color="#AEAEB0"/>
     </div>
  </div>
</van-swipe-item>

部分css代碼

.d-meet-top {
   display: flex;
   justify-content: space-between;
   transform: translateZ(0); // 《== 關鍵
}

 .d-meet-top div {
   display: flex;
   align-items: center;
}

ps:下面看下vue-輪播圖導致下方文字抖動問題

在使用vantui的swipe組件時遇到下方文字抖動的問題

解決方案:在樣式裡加入 transform: translateZ(0)

<van-swipe :autoplay="3000">
 <van-swipe-item v-for="(swipeItem,index) of swipeList" 
 :key="index"
 @click="bannerJump(swipeItem.imgUrl,swipeItem.bannerId)">
 <div class="swipe-img-container">
  <img v-lazy="swipeItem.img" class="swipe-img">
 </div>
 </van-swipe-item>
</van-swipe>
/deep/ .van-swipe {
    text-align: center;
    background-color: white;
    transform: translateZ(0);
  }

到此這篇關於解決vue使用vant輪播組件swipe + flex時文字抖動問題的文章就介紹到這瞭,更多相關vue使用vant輪播組件文字抖動內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: