xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

vue router to from All In One

vue router to from All In One

vue watch $route

// eslint-disable-next-line no-new
new Vue({
    router,
    store,
    render: h => h(App),
    watch: {
        $route (to, from) {
            // const {
            //     name,
            //     // id,
            // } = UtilCache.getLocalItem('userInfo');
            console.log('to.path', to, to.path);
            // ...
         }
    }
}).$mount('#app');


next(to) bug ❌


router.beforeEach((to, from, next) => {
    // ._t 时间戳 ?
    // console.log('to.query._t', to.query._t);
    if (typeof to.query._t !== 'undefined') {
        next();
    } else {
        to.query._t = parseInt(new Date().getTime() / 1000);
        // bug
        next(to);
    }
});


https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route

vue components watch $route ???

https://router.vuejs.org/api/#to

https://router.vuejs.org/api/#the-route-object

refs

https://flaviocopes.com/vue-router/



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-03-17 20:37  xgqfrms  阅读(116)  评论(5编辑  收藏  举报