一, 安装

  npm i vue-ins-progress-bar 

二, main.js

import VueInsProgressBar from 'vue-ins-progress-bar'

const options = {
  position: 'fixed',
  show: true,
  height: '3px'
}

Vue.use(VueInsProgressBar, options)

三, App.vue

<template>
  <div >
    <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>

四, APIs

this.$insProgress.start() // 开始回调
this.$insProgress.finish() // 结束回调
this.$insProgress.height(4) // 加载栏的高度调整为4px

Dome

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2021-08-18
  • 2021-10-31
  • 2021-11-17
  • 2021-08-22
  • 2022-12-23
猜你喜欢
  • 2021-10-29
  • 2022-12-23
  • 1970-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
相关资源
相似解决方案