• router--- index.js


    import Vue from 'vue';
    import Router from 'vue-router';
    import store from '../store';
    import Api from '../lib/api/api';

    import Homes from '../views/homes/homes';
    import Index from '../views/homes/index';


    Vue.use(Router);

    let router = new Router({
    // mode: 'history',
    routes: [
    { path: '/', redirect: '/login'},
    {
    path: '/home',
    name: 'home',
    component: Homes,
    children: [
    { path: '/', name: 'home', component: Index2},
    { path: '/index', name: 'index', component: Index},
    ]
    },
    { path: '/bet/:sign', name: 'bet', component: Bet},
    { path: '*', redirect: '/home'}
    ]
    });



    router.beforeEach((to, from, next) => {


    // 处理路由切换时 切换效果
    if(document.documentElement['scrollTop']) {
    document.documentElement.scrollTop = 0;
    } else {
    document.body.scrollTop = 0;
    }

    // 跳转路由 取消上个路由的请求
    if(store.state['axiosPromiseCancel'].length > 0) {
    store.state['axiosPromiseCancel'].forEach(e => {
    e && e.f()
    });
    }
    store.state['axiosPromiseCancel'] = [];

    if(!store.state.baseConfig.banner) {
    Api.baseConfig().then(response => {
    if (response.success) {
    store.state.baseConfig = response.data;
    }
    })
    }
    // 是否加密
    // Api.isCryptData().then( response => {
    // if (response['success']) {
    // window.isCryptData = response['data'];
    //
    // }
    // });
    next();

    });

    export default router;
  • 相关阅读:
    1.1图形验证码的生成
    1.3蓝图导入问题
    1.2数据库迁移
    1.1首页显示
    1.3 日志配置以及蓝图的抽取
    1.2 app工厂以及db问题的解决
    每日总结
    每日总结
    每日总结
    每日总结
  • 原文地址:https://www.cnblogs.com/zhaofeis/p/12797954.html
Copyright © 2020-2023  润新知