【发布时间】:2019-02-14 04:26:51
【问题描述】:
我正在开发一个原型,所以有些字段是硬编码的。 我可以知道为什么下面会抛出错误吗?
vue.runtime.esm.js:587 [Vue warn]: Property or method "A" 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. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <Recommendation> at components/Recommendations.vue
<HomePage> at pages/profile.vue
<Nuxt>
<Default> at layouts/default.vue
<Root>
Recommendations.vue
<template>
<div class="recommendations">
<div class="recommendations__content">
<AppOption :selected="A"></AppOption>
<AppOption :selected="B"></AppOption>
<AppOption :selected="C"></AppOption>
</div>
</div>
</template>
<script>
import AppOption from '@/components/Option.vue'
export default {
name: 'Recommendation',
components: {
AppOption
},
data() {
return {
}
}
}
</script>
Option.vue
<template>
<div>
<b-field>
<b-select
placeholder="Select skill"
v-model="current"
size="is-medium"
expanded>
<template v-for="option in options">
<option :value="option.value" v-bind:key="option.value">{{ option.title }} </option>
</template>
</b-select>
</b-field>
<div class="recommendations__content__row">
<div class="fieldset">
<label>Current:</label>
**<input type="text" value="6.0" disabled>**
</div>
<div class="fieldset">
<label>Goal:</label>
<input type="text" value="8.0">
</div>
</div>
</div>
</template>
<script>
export default {
props: ['selected'],
data() {
return {
current: this.selected,
options: [
{ title: 'Skill A', value: 'A', points: 6},
{ title: 'Skill B', value: 'B', points: 5},
{ title: 'Skill C', value: 'C', points: 4}
]
}
}
}
</script>
另外,如何根据父页面选择的内容将 Option.vue 中以“**”突出显示的部分更新为 JSON 中的“点”?
【问题讨论】:
标签: javascript json node.js vue.js nuxt.js