想在 vue 項目中擁有 instagram 那種絢麗的彩虹進度條? 不如試試這個vue
a vue component of ins-style progress bar
git
一款 ins 風格的 vue 進度條組件
github
Live Demonpm
npm i vue-ins-progress-bar
複製代碼
main.js
bash
import VueInsProgressBar from 'vue-ins-progress-bar'
const options = {
position: 'fixed',
show: true,
height: '3px'
}
Vue.use(VueInsProgressBar, options)
複製代碼
App.vue
app
<template>
<div id="app">
<router-view/>
<vue-ins-progress-bar></vue-ins-progress-bar>
</div>
</template>
<script>
export default {
name: 'App',
mounted () {
this.$insProgress.finish()
},
created () {
this.$insProgress.start()
this.$router.beforeEach((to, from, next) => {
this.$insProgress.start()
next()
})
this.$router.afterEach((to, from) => {
this.$insProgress.finish()
})
}
}
</script>
複製代碼
this.$insProgress.start() // start the loading
複製代碼
this.$insProgress.finish() // finish the loading
複製代碼
this.$insProgress.height(4) // resize the height of loading bar to 4px
複製代碼
Repository: vue-ins-progress-barthis
Author: @meloalrightspa
MITcode