自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

使用這 6個(gè)Vue加載動(dòng)畫庫來減少我們網(wǎng)站的跳出率

開發(fā) 前端
阻止人們離開我們的網(wǎng)站的一種方法是添加視覺反饋,讓他們知道我們的網(wǎng)頁正在加載而不是壞了。

[[398663]]

阻止人們離開我們的網(wǎng)站的一種方法是添加視覺反饋,讓他們知道我們的網(wǎng)頁正在加載而不是壞了。視覺反饋還吸引了人們的注意力,因此等待時(shí)間似乎比靜態(tài)屏幕要短得多。

無論是添加微調(diào)動(dòng)畫還是添加實(shí)際進(jìn)度條,提供美觀的視覺元素都可以改善網(wǎng)站的性能,也會(huì)讓訪問者體驗(yàn)更加的好。

對于Vue開發(fā)人員而言,有大量類似的庫供我們使用。

在本文中,分享 6 個(gè)我的最愛。

1. Vue Simple Spinner

github:https://dzwillia.github.io/vue-simple-spinner/examples/

顧名思義,這是一個(gè)非常簡單的組件,但功能仍然非常強(qiáng)大。Vue Simple Spinner提供了可定制加載樣式。使用 props,我們可以控制對應(yīng)的樣式:

  • Size
  • Background and foreground colors
  • Speed
  • Label Text
  • Much more…

安裝命令:

  1. npm install vue-simple-spinner --save. 

然后,將其導(dǎo)入到組件中,在模板中進(jìn)行聲明,然后更改所需的 props:

  1. <template> 
  2.    <vue-simple-spinner size="medium" /> 
  3. </template> 
  4. <script> 
  5. import VueSimpleSpinner from 'vue-simple-spinner' 
  6. export default { 
  7.    components: {  
  8.       VueSimpleSpinner 
  9.    } 

效果如下:

2. Vue Radial Progress

github 地址:https://github.com/wyzantinc/vue-radial-progress

如果你想要的是一個(gè)真正的進(jìn)度條而不是旋轉(zhuǎn)動(dòng)畫,Vue Radial Progress 一個(gè)非常棒的庫。

Vue Radial Progress 可以在在進(jìn)度欄中設(shè)置步驟數(shù)以及用戶當(dāng)前所處的步驟。然后,根據(jù)完成的數(shù)量填充進(jìn)度條的一定百分比。

具有平滑的動(dòng)畫,可自定義的功能以及基于SVG的填充系統(tǒng),當(dāng)您具有包含多個(gè)離散步驟的異步過程時(shí),此庫將非常強(qiáng)大。

安裝:

  1. npm install --save vue-radial-progress 

此外,該庫使用組件插槽使圓內(nèi)添加文本變得簡單

  1. <template> 
  2.   <radial-progress-bar :diameter="200" 
  3.                        :completed-steps="completedSteps" 
  4.                        :total-steps="totalSteps"
  5.    <p>Total steps: {{ totalSteps }}</p> 
  6.    <p>Completed steps: {{ completedSteps }}</p> 
  7.   </radial-progress-bar> 
  8. </template> 
  9.  
  10. <script> 
  11. import RadialProgressBar from 'vue-radial-progress' 
  12.  
  13. export default { 
  14.   data () { 
  15.     return { 
  16.       completedSteps: 0, 
  17.       totalSteps: 10 
  18.     } 
  19.   }, 
  20.  
  21.   components: { 
  22.     RadialProgressBar 
  23.   } 
  24. </script> 

3.Vue Loading Overlay

github: https://github.com/ankurk91/vue-loading-overlay

**Vue Loading Overlay **是全屏加載組件的理想解決方案。例如,如果應(yīng)用程序包含某種儀表板,并且要等到所有數(shù)據(jù)加載完畢后再讓用戶四處點(diǎn)擊,則此庫很有用。

這個(gè)庫還有一個(gè)好用的特性就是加載時(shí),用戶點(diǎn)擊遮罩,可以取消加載,并觸發(fā)一個(gè)事件,我們可以使用該事件取消正在運(yùn)行的任何任務(wù)。

添加此功能,可以允許用戶自行決定任務(wù)何時(shí)花費(fèi)太長時(shí)間來加載和退出。這意味著他們不必離開頁面。

安裝命令:

  1. npm install --save vue-loading-overlay 

下面是 Loading Overlay library 使用示例:

  1. <template> 
  2.     <div class="vld-parent"
  3.         <loading :active.sync="isLoading"  
  4.         :can-cancel="true"  
  5.         :on-cancel="onCancel" 
  6.         :is-full-page="fullPage"></loading> 
  7.          
  8.         <label><input type="checkbox" v-model="fullPage">Full page?</label> 
  9.         <button @click.prevent="doAjax">fetch Data</button> 
  10.     </div> 
  11. </template> 
  12.  
  13. <script> 
  14.     // Import component 
  15.     import Loading from 'vue-loading-overlay'
  16.     // Import stylesheet 
  17.     import 'vue-loading-overlay/dist/vue-loading.css'
  18.      
  19.     export default { 
  20.         data() { 
  21.             return { 
  22.                 isLoading: false
  23.                 fullPage: true 
  24.             } 
  25.         }, 
  26.         components: { 
  27.             Loading 
  28.         }, 
  29.         methods: { 
  30.             doAjax() { 
  31.                 this.isLoading = true
  32.                 // simulate AJAX 
  33.                 setTimeout(() => { 
  34.                   this.isLoading = false 
  35.                 },5000) 
  36.             }, 
  37.             onCancel() { 
  38.               console.log('User cancelled the loader.'
  39.             } 
  40.         } 
  41.     } 
  42. </script> 

4. Vue Progress Path

github 地址:https://github.com/Akryum/vue-progress-path

Vue Progress Path 是最流行的加載庫之一。由 Vue Core團(tuán)隊(duì)成員Guillaume Chau創(chuàng)建,這也是我最喜歡使用的工具之一。

使用 SVG,Vue Progress Path 會(huì)創(chuàng)建成形的進(jìn)度條。它帶有幾個(gè)內(nèi)置的形狀,但是最強(qiáng)大的功能是能夠傳遞我們自己的SVG形狀-這意味著無限的可能性。

使用npm i --save vue-progress-path將其添加到項(xiàng)目中,然后使用將該文件全局添加到src/main.js文件中。

  1. import 'vue-progress-path/dist/vue-progress-path.css' 
  2. import VueProgress from 'vue-progress-path' 
  3.  
  4. Vue.use(VueProgress, { 
  5.   // defaultShape: 'circle'
  6. }) 

現(xiàn)在,來看看如何向組件添加進(jìn)度 path 。

  1. <loading-progress 
  2.   :progress="progress" 
  3.   :indeterminate="indeterminate" 
  4.   :counter-clockwise="counterClockwise" 
  5.   :hide-background="hideBackground" 
  6.   shape="semicircle" 
  7.   size="64" 
  8. /> 

這個(gè)庫還有一個(gè)很好地方,更改樣式無須通過 props ,直接使用CSS代碼來編輯樣式:

  1. .vue-progress-path path { 
  2.   stroke-width: 12; 
  3.  
  4. .vue-progress-path .progress { 
  5.   stroke: red; 

5. Vue Loading Button

github 地址:https://github.com/shwilliam/vue-loading-button

Vue Loading Button 是一種簡單而有效的方式,可以向用戶顯示某些內(nèi)容正在加載。

它所做的只是在按鈕被點(diǎn)擊時(shí)添加一個(gè)轉(zhuǎn)輪動(dòng)畫。但有了平滑的動(dòng)畫,它可以創(chuàng)建一個(gè)無縫的外觀,使網(wǎng)站流行。

安裝:

  1. npm install --save vue-loading-button 

示例:

  1. <template> 
  2.    <VueLoadingButton aria-label='Send message' /> 
  3. </template> 
  4. <script> 
  5. import VueLoadingButton from 'vue-loading-button' 
  6.  
  7. export default { 
  8.   components: { 
  9.     VueLoadingButton, 
  10.   } 
  11. </script> 

6. TB Skeleton

github 地址:https://github.com/anthinkingcoder/tb-skeleton

TBSkeleton 的體驗(yàn)是非常好的。但是,這需要相當(dāng)繁瑣的代碼,也要合理的規(guī)劃元素。

我認(rèn)為理解這一點(diǎn)的最好方法就是寫個(gè)例子。

首先,使用npm install --save tb-skeleton安裝。然后,將下面內(nèi)容添加到src/main.js文件中。

  1. import skeleton from 'tb-skeleton' 
  2. import  'tb-skeleton/dist/skeleton.css' 
  3. Vue.use(skeleton) 

下面是 TBSkeleton 文檔中的骨架組件示例。

  1. <template> 
  2.   <div> 
  3.     <skeleton :theme="opacity" :shape="radius" :bg-color="#dcdbdc"
  4.      <tb-skeleton  width="30%" :aspect-ratio="1"  :shape="circle" bg-color="#eee"></tb-skeleton> 
  5.      <tb-skeleton  width="30%" :aspect-ratio=".3"></tb-skeleton> 
  6.      <tb-skeleton  width="30%" :aspect-ratio=".3"></tb-skeleton> 
  7.    </skeleton> 
  8.   </div> 
  9. </template> 
  10. <script> 
  11.   import {TbSkeleton,Skeleton} from 'tb-skeleton' 
  12.   export default { 
  13.     components: { 
  14.       TbSkeleton, 
  15.       Skeleton 
  16.     } 
  17.   } 
  18. </script> 

 

如上所見,如果要使用這個(gè)庫,需要一些時(shí)間成本,但在一些需要用戶體驗(yàn)極好的需求里,可以使用它。

~ 完,我是刷碗智,去刷碗咯了,下期見~

作者:Matt Maribojoc 譯者:前端小智 來源:stackabuse

原文:https://learnv.co/2020/02/6-vue-loader-animaon-libraries-to-reduce-your-bou

本文轉(zhuǎn)載自微信公眾號「大遷世界」,可以通過以下二維碼關(guān)注。轉(zhuǎn)載本文請聯(lián)系大遷世界公眾號。

 

責(zé)任編輯:武曉燕 來源: 大遷世界
相關(guān)推薦

2019-12-20 10:00:57

技術(shù)數(shù)據(jù)實(shí)踐

2020-09-28 15:14:46

網(wǎng)站科技技術(shù)

2011-05-27 15:16:37

網(wǎng)站跳出率

2011-05-27 10:34:00

CSS Sprites網(wǎng)站加載時(shí)間

2021-09-09 08:23:11

Vue 技巧 開發(fā)工具

2021-11-17 16:24:23

JS 代碼函數(shù)聲明

2011-05-11 17:26:17

Minify

2021-04-21 07:51:06

Vue 開發(fā)VS CodeVetur

2020-10-18 12:53:29

黑科技網(wǎng)站軟件

2011-06-22 17:04:27

網(wǎng)站收錄

2019-07-12 09:32:36

Wi-Fi 網(wǎng)絡(luò)標(biāo)準(zhǔn)

2021-07-21 05:22:12

Webpack 前端 JavaScript

2017-12-15 10:01:45

2020-06-18 09:55:50

Windows微軟工具

2018-10-19 11:07:02

主流緩存更新

2023-11-02 10:24:34

2016-08-08 13:08:01

2018-05-14 17:33:28

學(xué)習(xí)編程課程

2022-02-08 15:55:00

Vue組件庫Vue Demi

2021-08-01 07:58:58

Vue 加載組件
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號