stefan7
250
4
Vue

Router link error

Posted 6 months ago by stefan7

Hi, in app.js i defined:

import CommentsIndex from './components/comments/CommentsIndex.vue';
import CommentsCreate from './components/comments/CommentsCreate.vue';
import CommentsEdit from './components/comments/CommentsEdit.vue';

const routes = [
    {
        path: '/',
        components: {
            commentsIndex: CommentsIndex
        }
    },
    {path: '/admin/comments/create', component: CommentsCreate, name: 'createComment'},
    {path: '/admin/comments/edit/:id', component: CommentsEdit, name: 'editComment'},
]

Then in CommentsIndex.vue there is the router link:

 <router-link :to="{name: 'createComment'}" class="btn btn-success">Create Comment</router-link>

But why is it not working?

vue.js:525 [Vue warn]: Missing required prop: "to" 
(found in component <RouterLink>)
warn @ vue.js:525
assertProp @ vue.js:1289

vue.js:525 [Vue warn]: Error when rendering component <RouterLink>: 
warn @ vue.js:525
Vue._render @ vue.js:2227

app.js:48624 Uncaught TypeError: Cannot read property 'name' of undefined
    at normalizeLocation (app.js:48624)

Please sign in or create an account to participate in this conversation.