-1π
β
As everyone explained you are not passing Array to NavigationDrawer
component. Currently, you havenβt binded Array so it is just string.
TIP: Use prop validation to mitigate this kind of issues
To solve your issue all you have to do is bind it using v-bind
<navigation-drawer
:links="[
{title='Google', link='https://www.google.ch'},
{title='Youtube', link='https://www.youtube.com'}
]"
/>
This should fix your issue.
1π
First, your object syntax is wrong. In js you should using :
not β=β to declare property in object.
[ {title='Google' , link='https://www.google.ch' },{ title='Youtube' ,link='https://www.youtube.com' } ]
And then you should using v-bind to tell vue links
itβs a JavaScript expression rather than a string.
You can direct declaration links like that.
<navigation-drawer
:links="[{title: 'Google', link: 'https://www.google.ch' }, { title: 'Youtube', link: 'https://www.youtube.com' }]"
/>
Also you can use a state to do that.
// template
<navigation-drawer :links="links"/>
// script
data() {
return {
links: [
{ title: "Google", link: "https://www.google.ch" },
{ title: "Youtube", link: "https://www.youtube.com" }
]
};
}
0π
Try this below in your App.vue
<template>
<div id="app">
<navigation-drawer :links="link_array"
/>
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
import NavigationDrawer from './components/Navigation-Drawer.vue'
export default {
name: 'App',
components: {
HelloWorld,
NavigationDrawer,
},
data(){
return {
link_array : "Your Array" < -----------
}
}
</script>
Source:stackexchange.com