Running into issues with the router and using an external component for the nav
See original GitHub issueFull source here.
I am receiving the following error by having my navigation menu as an external component:
[Vue warn]: Failed to resolve directive: link (found in anonymous component - use the "name" option for better debugging messages.))
Now after a bit of googling I think it is related to this.
Which is something to do with the component being external.
App.vue:
<template>
<div id="app">
<div class="container">
<navigation></navigation>
<router-view></router-view>
</div>
</div>
</template>
<script>
import Navigation from './components/Navigation'
export default {
components: {
Navigation,
}
}
</script>
Navigation.vue:
<template>
<div class="navigation">
<div class="grid -middle">
<div class="cell -3of12">
<h1>Otis Wright</h1>
</div>
<div class="cell -9of12">
<ul class="menu">
<li>
<a v-link="{ path: 'home' }">Home</a>
</li>
<li>
<a v-link="{ path: '/projects' }">Projects</a>
</li>
<li>
<a href="#">Experiments</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</div>
</div>
</div>
</template>
But after looking at the routes
I can not figure out what is going wrong?
index.js:
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
mode: 'hash',
routes: [
{
path: '/',
component: require('../views/Home')
},
{
path: '/projects',
component: require('../views/Projects')
}
]
})
Sorry still learning Vue and I am probably missing something really simple, the routes are being handled slightly differently to what I am used to so I can’t quite figure it out.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
[Bug]: How to navigate outside React context in v6? #8264
Being able to control navigation outside React components is something you just need in some cases. Hooks are great, but we can't use...
Read more >How to handle navigation in your app with React Router Link
The first two will use the Link and NavLink components, while the last one will make use of the Redirect component. Let's get...
Read more >You should not use <Link> outside a <Router> - Stack Overflow
This error message is essentially saying that any component that is not a child of our <Router> cannot contain any React Router related ......
Read more >How To Use Routing with React Navigation in React Native
This library helps solve the problem of navigating between multiple screens and sharing data between them. At the end of this tutorial, you ......
Read more >React Router DOM: How to handle routing in web apps
Most of the time, you'll use a <Link> component to change the location. <Link>. Let's create a navigation menu. Open src/App.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, I misunderstand you.
There’s no
v-link
directive invue-router
2Using a component called
<router-link>
instead:@egoist i try this solution but dosn’t work with that my error [Vue warn]: Failed to resolve directive: link (found in anonymous component - use the “name” option for better debugging messages.)