import Vue from 'vue'; import VueRouter from 'vue-router'; import VueWechatTitle from 'vue-wechat-title'; Vue.use(VueRouter); Vue.use(VueWechatTitle); // 路由懒加载 const routes = [ { path: '/', redirect: '/payment', }, { path: '/payment', name: 'Payment', component: () => import('../views/payment/Index.vue'), meta: { title: '在线缴费' }, }, { path: '/payment/prepay', name: 'PrepayBills', component: () => import('../views/payment/PrepayBills.vue'), meta: { title: '预缴账单' }, }, { path: '/payment/records', name: 'PaymentRecords', component: () => import('../views/payment/Records.vue'), meta: { title: '缴费记录' }, }, { path: '/payment/bill-detail/:billId', name: 'BillDetail', component: () => import('../views/payment/BillDetail.vue'), meta: { title: '账单详情' }, }, { path: '/payment/record-detail/:billId', name: 'RecordDetail', component: () => import('../views/payment/RecordDetail.vue'), meta: { title: '缴费详情' }, }, { path: '/payment/pay-result', name: 'PayResult', component: () => import('../views/payment/PayResult.vue'), meta: { title: '支付结果' }, }, { path: '/payment/enterprise-pay', name: 'EnterprisePay', component: () => import('../views/payment/EnterprisePay.vue'), meta: { title: '公对公支付' }, }, { path: '*', redirect: '/payment', }, ]; const router = new VueRouter({ routes, }); // 全局路由守卫 router.beforeEach((to, from, next) => { // 更新页面标题 if (to.meta.title) { document.title = to.meta.title; } next(); }); export default router;