diff --git a/lib/app/router.js b/lib/app/router.js index 2238ee8ef3..b49a436aa9 100644 --- a/lib/app/router.js +++ b/lib/app/router.js @@ -7,8 +7,9 @@ import Router from 'vue-router' route._name = '_' + hash(route.component) components.push({ _name: route._name, component: route.component, name: route.name, chunkName: route.chunkName }) res += tab + '{\n' - res += tab + '\tpath: ' + JSON.stringify(route.path) + ',\n' - res += tab + '\tcomponent: ' + (splitPages ? route._name : `() => ${route._name}.default || ${route._name}`) + res += tab + '\tpath: ' + JSON.stringify(route.path) + res += (route.component) ? ',\n\t' + tab + 'component: ' + (splitPages ? route._name : `() => ${route._name}.default || ${route._name}`) : '' + res += (route.redirect) ? ',\n\t' + tab + 'redirect: ' + JSON.stringify(route.redirect) : '' res += (route.name) ? ',\n\t' + tab + 'name: ' + JSON.stringify(route.name) : '' res += (route.children) ? ',\n\t' + tab + 'children: [\n' + recursiveRoutes(routes[i].children, tab + '\t\t', components) + '\n\t' + tab + ']' : '' res += '\n' + tab + '}' + (i + 1 === routes.length ? '' : ',\n') @@ -18,6 +19,7 @@ import Router from 'vue-router' const _components = [] const _routes = recursiveRoutes(router.routes, '\t\t', _components) %><%= uniqBy(_components, '_name').map((route) => { + if (!route.component) return '' const path = relativeToBuild(route.component) const chunkName = wChunk(route.chunkName) const name = route._name