欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Vue如何實現(xiàn)移動端頁面切換效果-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)Vue如何實現(xiàn)移動端頁面切換效果的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

為觀山湖等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及觀山湖網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都做網(wǎng)站、成都網(wǎng)站設(shè)計、觀山湖網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

為什么要使用Vue

Vue是一款友好的、多用途且高性能的JavaScript框架,使用vue可以創(chuàng)建可維護性和可測試性更強的代碼庫,Vue允許可以將一個網(wǎng)頁分割成可復(fù)用的組件,每個組件都包含屬于自己的HTML、CSS、JavaScript,以用來渲染網(wǎng)頁中相應(yīng)的地方,所以越來越多的前端開發(fā)者使用vue。

在子頁面把整個頁面做絕對定位,覆蓋整個屏幕,子父頁面將 router-view 用  transition 套起來,并加上過渡動畫就可以啦。

代碼:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
 <title>Document</title>
 <style>
  * { padding: 0; margin: 0; }
  html, body, #app { width: 100%; height: 100%; }
  .one { height: 100%; background-color: yellow; }
  .two { background-color: tomato; position: fixed; top: 0; bottom: 0; left: 0; right: 0; }
  .three { background-color: #ffe69f; position: fixed; top: 0; bottom: 0; left: 0; right: 0; }
  .v-enter-active, .v-leave-active { transition: all 0.3s; }
  .v-enter, .v-leave-to { transform: translateX(100%); }
 </style>
</head>
<body>
 <div id="app">
  <div class="one">
   <p>
    <router-link to="/foo">下一層</router-link>
   </p>
   <h2>第一層</h2>
  </div>
  <transition>
   <router-view></router-view>
  </transition>
 </div>

 <script src="https://unpkg.com/vue/dist/vue.js"></script>
 <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
 <script>
  const Foo = {
   template: `
    <div class="whole-page two">
     <router-link to="/foo/bar">下一層</router-link>
     <router-link to="/">返回</router-link>
     <h2>第二層</h2>
     <transition>
      <router-view></router-view>
     </transition>
    </div>
   `
  }
  const Bar = {
   template: `
    <div class="whole-page three">
     <router-link to="/foo">返回</router-link>
     <h2>第三層</h2>
     <transition>
      <router-view></router-view>
     </transition>
    </div>
   `
  }
  const routes = [ 
   { path: '/foo', component: Foo, children: [ { path: 'bar', component: Bar } ] }
  ]
  const router = new VueRouter({ routes })
  const app = new Vue({ router }).$mount('#app')
 </script>
</body>
</html>

效果:

Vue如何實現(xiàn)移動端頁面切換效果

有一個問題需要注意一下,

我們知道,在應(yīng)用transform屬性的時候,fixed定位會變成absolute。

這里,頁面轉(zhuǎn)換的時候,就變成了相對translation定位。所以如果子頁面中有絕對定位的話,移動的過程中頁面會變形。

簡單舉個栗子,

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
 <title>Document</title>
 <style>
* { padding: 0; margin: 0; }
html, body, #app { width: 100%; height: 100%; }
#app { padding-top: 50px; }
.one { height: 100%; background-color: yellow;}
.two { background-color: tomato; position: fixed; top: 100px; bottom: 0; left: 0; right: 0; }.v-enter-active, .v-leave-active { transition: all 0.3s; }
.v-enter, .v-leave-to { transform: translateX(100%); }
header { height: 50px; background-color: #000; width: 100%; position: fixed; top: 0; color: #fff; line-height: 50px; text-align: center; }
.two header { top: 50px; background-color: #666; }
 </style>
</head>
<body>
 <div id="app">
  <header>我是一個標(biāo)題</header>
  <div class="one">
   <p>
    <router-link to="/foo">下一層</router-link>
   </p>
   <h2>第一層</h2>
   <transition>
    <router-view></router-view>
   </transition>
  </div>
 </div>

 <script src="https://unpkg.com/vue/dist/vue.js"></script>
 <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
 <script>
  const Foo = {
   template: `
    <div class="whole-page two">
     <router-link to="/">返回</router-link>
     <header>我也是一個標(biāo)題</header>
     <h2>第二層</h2>
     <transition>
      <router-view></router-view>
     </transition>
    </div>
   `
  }
  const routes = [ 
   { path: '/foo', component: Foo }
  ]
  const router = new VueRouter({ routes })
  const app = new Vue({ router }).$mount('#app')
 </script>
</body>
</html>

看下效果:

Vue如何實現(xiàn)移動端頁面切換效果

OKOK,反正就是這種bug嘛。

解決辦法就是,就是,盡量讓頁面fixed定位都是0 0 0 0,然后偏移用padding實現(xiàn)。

大概吧……反正我是這么解決的……

比如上面那個可以把CSS改成這樣解決問題。

* { padding: 0; margin: 0; }
html, body, #app { width: 100%; height: 100%; }
#app { padding-top: 50px; }
.one { height: 100%; background-color: yellow;}
.two { background-color: tomato; position: fixed; top: 0; padding-top: 100px; bottom: 0; left: 0; right: 0; }.v-enter-active, .v-leave-active { transition: all 0.3s; }
.v-enter, .v-leave-to { transform: translateX(100%); }
header { height: 50px; background-color: #000; width: 100%; position: fixed; top: 0; color: #fff; line-height: 50px; text-align: center; z-index: 100; }
.two header { top: 50px; background-color: #666; }

嗯嗯 還有一個問題,還有個滑動穿透的問題

我再舉個栗子,

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
 <title>Document</title>
 <style>
* { padding: 0; margin: 0; }
html, body, #app { width: 100%; height: 100%; }
.one { min-height: 100%; background-color: yellow;}
.two { background-color: tomato; position: fixed; top: 0; bottom: 0; left: 0; right: 0; }
.three { background-color: #ffe69f; position: fixed; top: 50px; bottom: 0; left: 0; right: 0; }
.v-enter-active, .v-leave-active { transition: all 0.3s; }
.v-enter, .v-leave-to { transform: translateX(100%); }
 </style>
</head>
<body>
 <div id="app">
  <div class="one">
   <p>
    <router-link to="/foo">下一層</router-link>
   </p>
   <h2>第一層</h2><h2>第一層</h2><h2>第一層</h2><h2>第一層</h2><h2>第一層</h2>
   <h2>第一層</h2><h2>第一層</h2><h2>第一層</h2><h2>第一層</h2><h2>第一層</h2>
   <h2>第一層</h2><h2>第一層</h2><h2>第一層</h2><h2>第一層</h2><h2>第一層</h2>
   <transition>
    <router-view></router-view>
   </transition>
  </div>
 </div>

 <script src="https://unpkg.com/vue/dist/vue.js"></script>
 <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
 <script>
  const Foo = {
   template: `
    <div class="whole-page two">
     <router-link to="/">返回</router-link>
     <h2>第二層</h2>
     <transition>
      <router-view></router-view>
     </transition>
    </div>
   `
  }
  const routes = [ 
   { path: '/foo', component: Foo }
  ]
  const router = new VueRouter({ routes })
  const app = new Vue({ router }).$mount('#app')
 </script>
</body>
</html>

看效果,第二頁的高度明明就是視窗的高度,但是它有一個滾動條,實際上那是第一個頁面的滾動條。

網(wǎng)上找了好多方法,一一試了,全部不生效。(當(dāng)然很有可能是我的方法不對。

Vue如何實現(xiàn)移動端頁面切換效果

最后沒辦法只有找最笨的方法啦,就是通過 v-if 把父頁面不顯示就好了。

當(dāng)然不能直接不顯示,因為動畫還沒結(jié)束父元素就空白了呀!setTimeout 就好了……

感謝各位的閱讀!關(guān)于“Vue如何實現(xiàn)移動端頁面切換效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

網(wǎng)頁名稱:Vue如何實現(xiàn)移動端頁面切換效果-創(chuàng)新互聯(lián)
分享鏈接:http://aaarwkj.com/article36/pihsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、品牌網(wǎng)站設(shè)計外貿(mào)網(wǎng)站建設(shè)、ChatGPT域名注冊、小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計
伦理在线视频免费观看视频| 国产精品一区二区av不卡| 日本电影在线看一区二区| 又黄又湿又刺激中文字幕| 亚洲国产欧美日韩在线一区| 91精品国产91久久综合桃花| 偷拍一区二区三区夫妻| av免费观看日韩永久| 日本三级黄色免费的网站| 中文字幕人妻秘书社长| 日本精品国产一区二区在线| 国产自拍最新在线视频| 国产精品视频一区二区噜| 一本之道久久成人综合| 少妇人妻偷人精品系列| 风流少妇奶真白摸的好爽| 国内自拍韩国资源在线| 久久精品国产亚洲av麻| 日韩精品 视频二区| 日韩一区二区人妻在线| 日韩中文字幕专区在线| 99久久免费中文字幕| 国产97精品在线播放| 中文字幕在线五月婷婷| 强暴美女视频大全久久久| 欧美精品日本一区二区| 国产亚洲男人av一区三区| 中文字幕亚洲欧美日韩高清| 男女真人啪啪视频免费| 成人看片亚欧大片在线观看 | 久久精品国产亚洲夜色av网站| 欧美日韩一区二区三区福利| av在线男人社区日韩| 男人天堂手机视频在线| 一区二区三区欧美影片| 亚洲欧美激情国产综合久久| 成年人正常性生活频率| 人妻少妇中文字幕久久| 男男啪啪猛进猛出无遮挡| 亚洲成av人亚洲av| 欧美日韩国产精品综合|