這篇文章主要介紹了Vue使用NProgress的操作過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
NProgress是頁面跳轉是出現在瀏覽器頂部的進度條
官網:http://ricostacruz.com/nprogress/
github:https://github.com/rstacruz/nprogress
綠色的進度條就是NProgress實現的效果
安裝
$ npm install --save nprogress 或者$ yarn add nprogress//用法NProgress.start();NProgress.done();
使用
//導入import NProgress from 'nprogress'import 'nprogress/nprogress.css'router.beforeEach((to, from, next) => { NProgress.start() next()})router.afterEach(() => { NProgress.done()})
在App.vue中的style中增加:
#nprogress .bar { background: red !important; //自定義顏色 }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網之家。
新聞熱點
疑難解答