1、首先在nuxt.config.js配置 ``` /* ** 路由 */ router: { prefetchLinks: false, // 添加自定义路由 extendRoutes(routes, resolve) { require('./router/routes')(routes, resolve, __dirname) }, } ``` 2、路由重写 ``` /** * 匹配的优先级就按照路由的定义顺序:谁先定义的,谁的优先级就最高。 * push: 往后最加---所以自动生成的路由优先级比自定义路由高,匹配自动路由 * unshift:往前最加---所以自动生成的路由优先级比自定义路由低,匹配自定义路由 * **/ module.exports = function (routes, resolve, __dirname) { routes.unshift({ // 首页 重定向 path: '/index', redirect: '/' },{ // 首页 重定向 path: '/index.html', redirect: '/' },{ // 专区 慢病药馆 name: 'channel/manbing', path: '/channel/manbing.html', component: resolve(__dirname, 'pages/channel/manbing.vue') },{ // 专区 name: 'channel/pageno', path: '/channel/:pageno.html', component: resolve(__dirname, 'pages/channel/_pageno.vue') },{ // 登录 name: 'login/index', path: '/login.html', component: resolve(__dirname, 'pages/login/index.vue') },{ // 修改账号 name: 'login/changename', path: '/changename.html', component: resolve(__dirname, 'pages/login/changename.vue') },{ // 选择频道 name: 'login/selectcompany', path: '/selectcompany.html', component: resolve(__dirname, 'pages/login/selectcompany.vue') },{ // 注册 name: 'login/register', path: '/register.html', component: resolve(__dirname, 'pages/login/register.vue') },{ // 找回密码 name: 'login/findpwd', path: '/findpwd.html', component: resolve(__dirname, 'pages/login/findpwd.vue') },{ // 提交资质 name: 'login/audit', path: '/audit.html', component: resolve(__dirname, 'pages/login/audit.vue') },{ // 注册 网站协议 name: 'login/agreement', path: '/agreement.html', component: resolve(__dirname, 'pages/login/agreement.vue') },{ // 列表 name: 'list/index', path: '/list.html', component: resolve(__dirname, 'pages/list/index.vue') },{ // 搜索 name: 'list/search', path: '/search.html', component: resolve(__dirname, 'pages/list/search.vue') },{ // 全部分类 name: 'list/sort', path: '/sort.html', component: resolve(__dirname, 'pages/list/sort.vue') },{ // 商品 name: 'products/index', path: '/products/:id.html', component: resolve(__dirname, 'pages/products/_index.vue') },{ // 采购商中心 name: 'customer/index', path: '/customer.html', component: resolve(__dirname, 'pages/customer/index.vue') },{ // 地址 name: 'customer/address', path: '/address.html', component: resolve(__dirname, 'pages/customer/address.vue') },{ // 设置 name: 'setting/index', path: '/setting.html', component: resolve(__dirname, 'pages/setting/index.vue') },{ // 关于我们 name: 'setting/abus', path: '/setting/abus.html', component: resolve(__dirname, 'pages/setting/abus.vue') },{ // 售后服务 name: 'saleserver/index', path: '/saleserver.html', component: resolve(__dirname, 'pages/saleserver/index.vue') },{ // 商品签收 name: 'saleserver/signfor', path: '/saleserver/signfor.html', component: resolve(__dirname, 'pages/saleserver/signfor.vue') },{ // 退换货政策 name: 'saleserver/repolicy', path: '/saleserver/repolicy.html', component: resolve(__dirname, 'pages/saleserver/repolicy.vue') },{ // 退换货流程 name: 'saleserver/reflow', path: '/saleserver/reflow.html', component: resolve(__dirname, 'pages/saleserver/reflow.vue') },{ // 退款流程及说明 name: 'saleserver/refund', path: '/saleserver/refund.html', component: resolve(__dirname, 'pages/saleserver/refund.vue') },{ // 收藏 name: 'collect/refund', path: '/collect.html', component: resolve(__dirname, 'pages/collect/index.vue') },{ // 进货单 name: 'carts/index', path: '/carts.html', component: resolve(__dirname, 'pages/carts/index.vue') },{ // 添加退货信息 name: 'order/insertreturninfo', path: '/order/insertreturninfo.html', component: resolve(__dirname, 'pages/order/insertreturninfo.vue') },{ // 订单详情 name: 'order/detail_id', path: '/order/detail:id.html', component: resolve(__dirname, 'pages/order/detail_id.vue') },{ // 申请退款 name: 'order/askregoods_id', path: '/order/askregoods:id.html', component: resolve(__dirname, 'pages/order/askregoods_id.vue') },{ // 订单列表 name: 'order/list_status', path: '/order/list:status.html', component: resolve(__dirname, 'pages/order/list_status.vue') },{ // 退货列表 name: 'order/returnlist_status', path: '/order/returnlist:status.html', component: resolve(__dirname, 'pages/order/returnlist_status.vue') },{ // 购买页 name: 'purchase/index', path: '/purchase.html', component: resolve(__dirname, 'pages/purchase/index.vue') },{ // 付款单页 name: 'purchase/payment', path: '/payment.html', component: resolve(__dirname, 'pages/purchase/payment.vue') },{ // 支付成功回调 name: 'purchase/result', path: '/purchase/result.html', component: resolve(__dirname, 'pages/purchase/result.vue') },{ // 付款方式 name: 'purchase/paytype', path: '/purchase/paytype.html', component: resolve(__dirname, 'pages/purchase/paytype.vue') }) } ```