最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue配置nprogress實(shí)現(xiàn)頁面頂部進(jìn)度條

 更新時(shí)間:2019年09月21日 14:48:12   作者:人間草木96  
這篇文章主要為大家詳細(xì)介紹了vue配置nprogress實(shí)現(xiàn)頁面頂部進(jìn)度條,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue配置nprogress實(shí)現(xiàn)頁面頂部進(jìn)度條的具體代碼,供大家參考,具體內(nèi)容如下

1. 安裝

npm install nprogress --save

2. 在main.js中導(dǎo)入

源碼~~~~~~方便你復(fù)制 

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import iView from 'iview'
import 'iview/dist/styles/iview.css'
import moment from './plugins/moment'
import axios from './plugins/axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { base } from './router/config'
 
Vue.use(iView)
Vue.use(moment)
Vue.use(axios)
 
Vue.config.productionTip = false
 
// 配置NProgress進(jìn)度條選項(xiàng) —— 動(dòng)畫效果
NProgress.configure({ ease: 'ease', speed: 500 })
 
// 全局路由攔截-進(jìn)入頁面前執(zhí)行
router.beforeEach((to, from, next) => {
 if (to.path === `${base}login`) {
 return next()
 }
 
 // token驗(yàn)證,如果存儲在sessionStorage里的auth的值丟失,就回到登陸頁面,(開發(fā)時(shí)可以注釋掉)
 // if (!sessionStorage.getItem('auth')) {
 // return next(`${base}login`)
 // }
 
 // 如果頁面在 / 默認(rèn)頁面,跳轉(zhuǎn)到登陸頁面(和vue路由重定向功能類似)
 if (to.path === `${base}`) {
 return next(`${base}login`)
 }
 // NProgress開始進(jìn)度條
 NProgress.start()
 next()
})
 
// 全局后置鉤子-常用于結(jié)束動(dòng)畫等
router.afterEach(transition => {
 // NProgress結(jié)束進(jìn)度條
 NProgress.done()
 // console.log(transition)
})
 
/* eslint-disable no-new */
new Vue({
 el: '#app',
 router,
 components: { App },
 template: '<App/>'
})

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

兴山县| 桂平市| 河北省| 江津市| 绥宁县| 高雄县| 雷山县| 密云县| 平舆县| 若尔盖县| 惠州市| 新乐市| 平阴县| 开江县| 同德县| 河西区| 五原县| 长治市| 鹰潭市| 海宁市| 醴陵市| 罗田县| 曲麻莱县| 梁山县| 谢通门县| 句容市| 金堂县| 天全县| 黎平县| 荃湾区| 花莲市| 南华县| 青海省| 北辰区| 金沙县| 自贡市| 黄平县| 黑龙江省| 稷山县| 西畴县| 济阳县|