hilongjw / vue-progressbar

A lightweight progress bar for vue
http://hilongjw.github.io/vue-progressbar
MIT License
1.46k stars 162 forks source link

为什么我 直接从一开始就是100%的进度? #78

Open shen-lan opened 6 years ago

shen-lan commented 6 years ago

1.main.js

import VueProgressBar from 'vue-progressbar';
Vue.use(VueProgressBar, {
    color: 'rgb(64,158,255)',
    failedColor: 'red',
    height: '2px',
    transition: {
        speed: '0.2s',
        opacity: '0.6s',
        termination: 300
    }
});

router.beforeEach((to, from, next) => {
    if (to.meta.requireAuth) {
        if (sessionStorage.getItem('adminManage')) {
            next();
        } else {
            next({
                path: '/'
            });
        }
    } else {
        next();
        if (to.path === '/') {
            sessionStorage.removeItem('adminManage');
        } //登录页清除登录信息
    }
    document.title = to.meta.title;
});

2.app.vue

export default {
    name: 'App',
    created() {
        this.$Progress.start();
        this.$router.beforeEach((to, from, next) => {
            this.$Progress.start();
            next();
        });

        this.$router.afterEach((to, from) => {
            this.$Progress.finish();
        });
    },
    mounted() {
        this.$Progress.finish();
    }
};

3.问题 从start就是100%的进度,finsh后进度条消失。 正常应该是有一个进度的过程的吧?

chiaweilee commented 5 years ago

try remove this:

mounted() {this.$Progress.finish();}