Ad

How Do I Use Vue-resource V-links Inside A Vueify Component?

- 1 answer

When using v-link="{ path: '/add' }" in my vueify (used with Laravel) component, I get a v-link can only be used inside a router-enabled app. or a <router-view> can only be used inside a router-enabled app. error.

Here is my main.js: http://laravel.io/bin/Kkj27

My code seems very similar to the example provided for nestedRoutes, I am not sure why this is not working.

Ad

Answer

This is all a little confusing to me (best practices for structuring Vue.js single page apps) but this is essentially what I did to make it work:

Vue.component('Todo', Todo);

And removing this whole thing:

var TodoApp = new Vue({
    el: '#app',

    components: { Todo }
});

After this, I can refer to the Todo component in the router.map function.

router.map({
    '/': {
        component: Todo,
        subRoutes: {

            '/bar': {
             ...
            },
   '/': {
        component: Todo,
        subRoutes: {

            '/bar': {
             ...
            },
            '/baz': {
                ...
            }
        }
    }
})
Ad
source: stackoverflow.com
Ad