十八 router.js

66 阅读1分钟
// router.js
import {RouterMount,createRouter} from 'uni-simple-router';

console.log( 111 , ROUTES )
const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,  
	// #ifdef H5
	routes : [	
				{
					path: "/pages/goods-detail",
					beforeEnter:(to,from,next)=>{
						console.log('详情');
						next("/login/login");
					}
				},
				...ROUTES, 
		]
	// #endif
	// #ifndef H5
	routes:[],
	// #endif
});

//全局路由前置守卫
router.beforeEach((to, from, next) => {
	console.log('前置')
	next();
});
// 全局路由后置守卫
router.afterEach((to, from) => {
    console.log('后置')
})

export {
	router,
	RouterMount
}