在挂载路由的时候我采用了分离式的写法将路由分离成两个文件
import customRoute from './customRoute'
let routes = [
{path: '/register', component: Register, hidden: true},
{path: '/login', component: Login, hidden: true},
{path: '/404', component: Err404, hidden: true},
{path: '/401', component: Err401, hidden: true},
{path: '*', redirect: '/404', hidden: true},
{
path: '/',
component: Layout,
redirect: '/dashboard',
name: '首页',
hidden: true,
children: [{path: 'dashboard', component: dashboard}]
}
].concat(customRoute)
export default new Router({
routes: routes
})
但是在用karma测试的时候会出现如下错误:
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
TypeError: undefined is not an object (evaluating 'route.path')
at http://localhost:9877webpack:///~/vue-router/dist/vue-router.esm.js:1100:0 <- index.js:186842
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
TOTAL: 0 SUCCESS
似乎是karma认为用concat()加载的路由还没有被定义,但是我在项目实际开发和打包的过程中都没有错误运行也正常,求解
请问这个问题解决了吗?