【发布时间】:2020-11-20 11:43:15
【问题描述】:
下面是子组件和父组件。我无法弄清楚我哪里出错了,但我无法将值数据从子组件传递到父组件。请帮我找出哪里出错了。
子组件
<template>
<div>
<v-btn class="red-button" @click.prevent="checkAgent('information')">
Information
</v-btn>
<v-btn class="red-button" @click.prevent="checkAgent('policies')">
Policies
</v-btn>
</div>
</template>
<script>
export default {
data: function () {
return {
}
},
methods: {
checkAgent(value) {
this.$emit('navigate', value);
},
}
};
</script>
父组件
<template>
<v-layout row wrap>
<v-flex xs12 sm12 lg12 >
<div class="account-section">
<Details @navigate="moveTo(value)"/>
</div>
</v-flex>
</v-layout>
</template>
<script>
import Details from 'views/agent/edit.vue';
export default {
components: {
Details,
},
data: function () {
return {
}
},
methods: {
moveTo(value) {
console.log(value)
},
},
};
</script>
【问题讨论】:
-
您似乎没有注册父模板中使用的
Details组件。是不是打错字了? -
@YomS。错字错误。请立即查看
-
@YomS。在 moveTo 方法中,值会引发错误属性或方法“值”未在实例上定义,但在渲染期间被引用。
标签: javascript vue.js vuejs2 vue-component vuetify.js