Skip to content

Failed to resolve directive: link & Unknown custom element: <router-view> #333

@commandantp

Description

@commandantp

Hi,

Don't understand what's happening.
I keep getting those errors and the link won't display / work no matter what I do.
I followed both the example from the documentation & tried a few other tutorials too. Always the same problem.

My HTML:

<body>
    <div id="app">
      <h1>Hello App!</h1>
      <p>
        <!-- use v-link directive for navigation. -->
        <a v-link="{ path: '/hello' }">Go to Foo</a>
      </p>
      <!-- route outlet -->
      <router-view></router-view>
    </div>

    <script src="./js/main-vue.js"></script>
</body>

My main-vue.js:

var Vue = require('vue')
var VueRouter = require('vue-router')

Vue.use(VueRouter)
Vue.config.debug = true;

// Set up our route


var router = new VueRouter();

router.map({
    '/hello': {
        component: {
            template: '<p>hello!</p>'
        }
    }
});



var App = Vue.extend({});

router.start(App, '#app');

See the full error log:

main-vue.js:3583[Vue warn]: Failed to resolve directive: link
main-vue.js:3589Error: Warning Stack Trace
    at warn (main-vue.js:3589)
    at assertAsset (main-vue.js:4513)
    at compileDirectives (main-vue.js:9635)
    at compileElement (main-vue.js:9257)
    at compileNode (main-vue.js:9214)
    at compileNodeList (main-vue.js:9396)
    at compileNodeList (main-vue.js:9397)
    at compileNodeList (main-vue.js:9397)
    at compile (main-vue.js:9001)
    at VueComponent.Vue._compile (main-vue.js:10642)
main-vue.js:3583[Vue warn]: Unknown custom element: <router-view> - did you register the component correctly?
main-vue.js:3589Error: Warning Stack Trace
    at warn (main-vue.js:3589)
    at checkComponentAttr (main-vue.js:4080)
    at checkComponent (main-vue.js:9461)
    at compileElement (main-vue.js:9253)
    at compileNode (main-vue.js:9214)
    at compileNodeList (main-vue.js:9396)
    at compileNodeList (main-vue.js:9397)
    at compile (main-vue.js:9001)
    at VueComponent.Vue._compile (main-vue.js:10642)
    at VueComponent.Vue.$mount (main-vue.js:11634)
backend.js:201 [vue-devtools] ready.

The only positive thing is that #! is added in the URL meaning something happens?
Node 5.4.1 & npm 3.5.3 & browserify & Laravel Elixir

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions