1、@nuxtjs/router 指定路由后出现:render function or template not defined in component: anonymous
- 基础解决方法:
import dispatch from '@/pages/dispatch/index.vue'
export function createRouter(){
return new VueRouter({
mode: "history",
routes: [
{
path: '/dispatch',
name: 'Dispatch',
component: dispatch,
}
]
});
}
- 升级版解决方法:
由于nuxtjs不支持路由懒加载,则考虑直接引入页面。
由于页面太多,vue2常见方式是:
const name = () => import('@/pages/name.vue')
按此思路,可考虑直接引入页面,即:
const name = require('@/pages/name.vue').default
批量引入页面:
module.exports = file => require('@/pages' + file + '.vue').default
网友评论