kyo*_*kyo 4 javascript vue.js vue-router vue-component vuejs2
我有
<template>
<div class="dashboard">
<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>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在尝试重用我的 MainPanel 组件。
主面板
<template>
<v-container fluid class="my-5">
<v-row>
<v-flex col-xs-12>
<v-card elevation="2" class="pb-15">
<v-flex xs12 class="text-center">
<v-card-title>
<v-btn dark text color="black">
<v-icon right class="mr-2">{{ 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>
Run Code Online (Sandbox Code Playgroud)
在控制台中,我不断收到此错误
[Vue warn]:属性或方法“dasboard”未在实例上定义,但在渲染期间引用。通过初始化该属性,确保该属性在数据选项中或对于基于类的组件是反应性的。
有人可以给我一些提示吗?
这似乎是一个非常简单的错误:
:title="Dashboard"
Run Code Online (Sandbox Code Playgroud)
在 Vue 中,使用列 ( :) 在组件上添加 prop 或属性,将使用 props 或 data 中定义的属性。如果你使用的话title="dashboard",你实际上会传递一个字符串,这就是你想要的
| 归档时间: |
|
| 查看次数: |
19495 次 |
| 最近记录: |