I have
<template>
<div >
<Navbar />
<MainPanel :title="Dashboard" :icon="dasboard" />
</div>
</template>
<script>
import MainPanel from '../../components/MainPanel'
import Navbar from '../../components/Navbar'
export default {
name: 'Dashboard',
components: {
Navbar,
MainPanel
}
}
</script>
As you can see, I'm trying to reuse my MainPanel component.
MainPanel
<template>
<v-container fluid >
<v-row>
<v-flex col-xs-12>
<v-card elevation="2" >
<v-flex xs12 >
<v-card-title>
<v-btn dark text color="black">
<v-icon right >{{ icon }}</v-icon>
<span>{{ title }}</span>
</v-btn>
</v-card-title>
</v-flex>
</v-card>
</v-flex>
</v-row>
</v-container>
</template>
<script>
export default {
name: 'MainPanel',
props: {
icon: String,
title: String
},
data() {
return {
icon: '',
title: ''
}
}
}
</script>
<style lang=""></style>
In the console, I kept getting this error
[Vue warn]: Property or method "dasboard" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
Can someone please give me some hints ?
CodePudding user response:
Using the binding sign :
when using raw values in props means that values should be present as properties inside the script options :
<MainPanel title="Dashboard" icon="dasboard" />
CodePudding user response:
It seems a very simple mistake:
:title="Dashboard"
in Vue using a column (:
) to prepend a prop or an attribute on a component, will use a property defined or in props or in data.
While if you use title="dashboard"
you'll actually pass a string, that is what you want