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;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM