使用vue實(shí)現(xiàn)加載頁
更新時(shí)間:2022年07月05日 13:09:55 作者:歌聲緩緩
這篇文章主要為大家詳細(xì)介紹了使用vue實(shí)現(xiàn)加載頁,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了用vue實(shí)現(xiàn)加載頁的具體代碼,供大家參考,具體內(nèi)容如下
<template> ? ? <div class="bac" style="height:1024px;display: flex;align-items: center;justify-content: center;"> ? ? ? ? <div class="wrap-content"> ? ? ? ? ? ? <img class="logo" src="../../assets/img/logo.png" :style="{'margin-left':percent}"> ? ? ? ? ? ? <div class="bar"> ? ? ? ? ? ? ? ? <div :style="{width:percent}" class="loadingBar"> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="percentFont">{{percent}}</div> ? ? ? ? ? ? <div class="fontTitle">報(bào)告生成中...</div> ? ? ? ? </div> ? ? </div> </template> <script> ? ? export default { ? ? ? ? name: "loading", ? ? ? ? data() { ? ? ? ? ? ? return{ ? ? ? ? ? ? ? ? count: 0, ? ? ? ? ? ? ? ? percent:'0', ? ? ? ? ? ? ? ? imgs:[ ? ? ? ? ? ? ? ? ? ? require("@/assets/img/bg.png"), ? ? ? ? ? ? ? ? ? ? require("@/assets/img/icon1.png"), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/icon2.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/icon3.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/icon4.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/icon5.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/icon6.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/loading-bg.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/logo.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/page3-title.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/pic1.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/pic2.png'), ? ? ? ? ? ? ? ? ? ? require('@/assets/img/pic3.png') ? ? ? ? ? ? ? ? ?) ? ? ? ? ? ? ? ? ] ? ? ? ? ? ? } ? ? ? ? }, ? ? ? ? mounted() { ? ? ? ? ? ? this.preload(); ? ? ? ? }, ? ? ? ? watch:{ ? ? ? ? ? ? count: function (val) { ? ? ? ? ? ? ? ? if ( val === this.imgs.length) { ? ? ? ? ? ? ? ? ? ? // 圖片加載完成后跳轉(zhuǎn)頁面 ? ? ? ? ? ? ? ? ? ? console.log(" 準(zhǔn)備就緒 >>>", val) ? ? ? ? ? ? ? ? ? ? this.$router.push({path: 'index'}) ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? }, ? ? ? ? methods:{ ? ? ? ? ? ? preload:function () { ? ? ? ? ? ? ? ? for (let img of this.imgs) { ? ? ? ? ? ? ? ? ? ? let image = new Image() ? ? ? ? ? ? ? ? ? ? image.src = img ? ? ? ? ? ? ? ? ? ? image.onload = () => { ? ? ? ? ? ? ? ? ? ? ? ? this.count++ ? ? ? ? ? ? ? ? ? ? ? ? // 計(jì)算圖片加載的百分?jǐn)?shù),綁定到percent變量 ? ? ? ? ? ? ? ? ? ? ? ? let percentNum = Math.floor(this.count / this.imgs.length * 100) ? ? ? ? ? ? ? ? ? ? ? ? if (percentNum == 100) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? percentNum = 99 ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? this.percent = `${percentNum}%` ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? } ? ? } </script> <style scoped> ? ? .bac { ? ? ? ? width: 100%; ? ? ? ? background: url("../../assets/img/loading-bg.png") no-repeat top right; ? ? ? ? background-size: 100% 100%; ? ? ? ? overflow: hidden; ? ? ? ? position: relative; ? ? } ? ? .logo{ ? ? ? ? width: 98px; ? ? ? ? height: 98px; ? ? } ? ? .percentFont { ? ? ? ? font-size: 32px; ? ? ? ? color: #046353; ? ? ? ? letter-spacing: 0.84px; ? ? ? ? text-align: center; ? ? ? ? margin-top: 32px; ? ? } ? ? .bar { ? ? ? ? margin-top: 50px; ? ? ? ? width: 300px; ? ? ? ? height: 8px; ? ? ? ? opacity: 0.8; ? ? ? ? background: #FFFFFF; ? ? ? ? border-radius: 4px; ? ? } ? ? .loadingBar { ? ? ? ? height: 8px; ? ? ? ? background-image: linear-gradient(-47deg, #046353 0%, #046353 100%); ? ? ? ? border-radius: 4px; ? ? } ? ? .fontTitle { ? ? ? ? margin-top: 12px; ? ? ? ? font-size: 32px; ? ? ? ? color: #046353; ? ? ? ? letter-spacing: 0.84px; ? ? ? ? text-align: center; ? ? ? ? font-weight: 400; ? ? } </style>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- vue實(shí)現(xiàn)加載頁面自動觸發(fā)函數(shù)(及異步獲取數(shù)據(jù))
- 使用Vue實(shí)現(xiàn)調(diào)用接口加載頁面初始數(shù)據(jù)
- 淺談Vue.js 關(guān)于頁面加載完成后執(zhí)行一個方法的問題
- VUE頁面中加載外部HTML的示例代碼
- vue.js頁面加載執(zhí)行created,mounted的先后順序說明
- 詳解vue頁面首次加載緩慢原因及解決方案
- 詳解Vue.js在頁面加載時(shí)執(zhí)行某個方法
- vue實(shí)現(xiàn)頁面加載動畫效果
- Vue 路由切換時(shí)頁面內(nèi)容沒有重新加載的解決方法
- 解決vue項(xiàng)目中頁面調(diào)用數(shù)據(jù) 在數(shù)據(jù)加載完畢之前出現(xiàn)undefined問題
相關(guān)文章
vue項(xiàng)目啟動后沒有局域網(wǎng)地址問題
這篇文章主要介紹了vue項(xiàng)目啟動后沒有局域網(wǎng)地址問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-09-09ElementUI級聯(lián)選擇器實(shí)現(xiàn)同一父級下最多只能選中一個子級
本文主要介紹了ElementUI級聯(lián)選擇器實(shí)現(xiàn)同一父級下最多只能選中一個子級,同一父級下的子節(jié)點(diǎn)單選,又可以選擇多個不同父級下的節(jié)點(diǎn),具有一定參考價(jià)值,感興趣的可以了解一下2023-10-10Vuex如何獲取getter對象中的值(包括module中的getter)
這篇文章主要介紹了Vuex如何獲取getter對象中的值(包括module中的getter),具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08Vue中的echarts圖表如何實(shí)現(xiàn)loading效果
這篇文章主要介紹了Vue中的echarts圖表如何實(shí)現(xiàn)loading效果,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08