解决vue页面过渡动画出现页面抖动效果或白屏问题

头部的header是绝对定位,每次动画调整,都有抖动一下或者是i闪烁一下
根本原因还是因为fixed在transform时失效了,所以要在动画进行过程中,用absolute覆盖掉fixed

<template>
  <div id="app">
    <!-- 头部导航区域 -->
    <div class="home-header">
      <p>首页</p>
    </div>
    <!--  中间路由 router-view 区域 -->
    <transition>
      <router-view class="page"></router-view>
    </transition>
    <!--  底部 Tabbar 区域  -->
    <div class="tabbar-chil">
      <Tabbar :page="1" style="position:absolute;"></Tabbar>
    </div>
  </div>
</template>

css 部分

<style>
#app {
  width: 100%;
  max-width: 640px;
  min-width: 320px;
  margin: auto;
  overflow-x: hidden;
}
/* 头部区域 */
.home-header{
  width: 100%;
  max-width: 640px;
  min-width: 320px;
  margin: auto;
  height: 1.4rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background-color: white;
  border-bottom: 1px solid #EAEAEA;
}
/*  中间部分动画  */
.v-enter{
  /*进入动画*/
  opacity: 0;
  transform: translateX(100%);
}
.v-leave-to{
  /*离开动画*/
  opacity: 0;
  transform: translateX(-100%);
  position: absolute;
}
.v-enter-active,
.v-leave-active{
  transition: all 0.5s ease;
}
/* fixed在transform时失效,可在动画进行过程中,用absolute覆盖掉fixed */
.page {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
/* tabbar区域 */
.tabbar-chil{
  width: 100%;
  max-width: 640px;
  min-width: 320px;
  margin: auto;
  height: 1.5rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  -webkit-transform: translateZ(0);
  background-color: white;
  border-top: 1px solid #EAEAEA;
}
</style>

fixed在transform时失效,可在动画进行过程中,用absolute覆盖掉fixed
给消失的元素加个 position: absolute;
主要是在上面这两句话

在你的动画节点上加入
.page {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
就好了
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 看了很多视频、文章,最后却通通忘记了,别人的知识依旧是别人的,自己却什么都没获得。此系列文章旨在加深自己的印象,因...
    DCbryant阅读 1,948评论 0 4
  • # 移动端开发 ### 1. 1px问题如何解决 #### ①伪类 + transform(比较完美) > 原理是...
    sunnyRube阅读 981评论 0 0
  • 一:在制作一个Web应用或Web站点的过程中,你是如何考虑他的UI、安全性、高性能、SEO、可维护性以及技术因素的...
    Arno_z阅读 1,346评论 0 1
  • 最近看到一篇关于GPU动画的神文,原文地址:https://www.smashingmagazine.com/20...
    purple_force阅读 3,624评论 1 6
  • Mobile Web Favorites 参与贡献 移动前端开发收藏夹,欢迎使用Issues以及 Pull Req...
    柴东啊阅读 935评论 0 2

友情链接更多精彩内容