Использую плагин
"@nuxtjs/router": "^1.4.0"
Вот так не работает
import Vue from 'vue'
import Router from 'vue-router'
import paths from './routes/paths'
Vue.use(Router)
function route (path, view, name, meta) {
return {
name: name || view,
path,
meta,
component: (resovle) => import(`~/pages/${view}.vue`).then(resovle)
}
}
export function createRouter() {
return new Router({
mode: 'history',
routes: paths.map(path => route(path.path, path.view, path.name, path.meta)).concat([{ path: "*", redirect: "/" }])
})
}
Вот так работает
import Vue from 'vue'
import Router from 'vue-router'
import Index from '~/pages/index.vue'
Vue.use(Router)
function route (path, view, name, meta) {
return {
name: name || view,
path,
meta,
component: Index
}
}
export function createRouter() {
return new Router({
mode: 'history',
routes: paths.map(path => route(path.path, path.view, path.name, path.meta)).concat([{ path: "*", redirect: "/" }])
})
}
Если я напрямую импортирую представление в роутер, то работает.
Затык вот здесь:
component: (resovle) => import(`~/pages/${view}.vue`).then(resovle)