javascript - Dynamically adding routing error
typecho
typecho 2017-07-05 10:49:44
0
2
899

I dynamically added a route and then an error was reported. The code for adding dynamic routing is as follows. Data is the data obtained from the background. I wrote a 404 page myself, and path: '/404' did not have this error.

data.permission = [{
    path: '/index',
    name: 'index',
    component: './../views/layout/index'
}]
this.$router.addRoutes(data.permission)

Then the following error is reported, please solve it

Uncaught (in promise) Error: [vue-router] route config "component" for path: /index cannot be a string id. Use an actual component instead.
typecho
typecho

Following the voice in heart.

reply all(2)
女神的闺蜜爱上我

Add a require in the component field, the error message was misunderstood

component:require('./../views/layout/index.vue')
学霸

component requires a component instance and cannot give a path
It can be introduced through import or require

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template