【发布时间】:2020-03-28 03:46:34
【问题描述】:
我正在尝试在 Vuejs 中创建一个组件,用户将在其中输入他/她的组织并将该数据传递给我的视图文件。
但这是我得到的:
[Vue 警告]:未知的自定义元素:
这是我的组件文件,用户将在其中输入他的组织。
<template>
<v-card class="mb-12">
<div class="px-7">
<Document :organization="organization"></Document>
<v-text-field label="Organization" filled></v-text-field>
</div>
</v-card>
</template>
<script>
import Document from "../views/vDocument";
export default {
components: {
Document
},
data() {
return {
organization: "Vincent"
};
}
};
</script>
这是我的视图文件,我将在其中将来自该组件的数据插入到数据库中:
<template>
<section>
<v-card class="px-5 py-5">
<v-card-title class="display-2 my-3">On-Campus Student Activity Application Form</v-card-title>
<v-card-subtitle>Please fill up these with correct information to assess your proposal</v-card-subtitle>
<v-stepper v-model="e1">
<v-stepper-header>
<v-stepper-step :complete="e1 > 1" editable step="1">Step 1</v-stepper-step>
</v-stepper-header>
<v-stepper-items>
<v-stepper-content step="1">
{{ organization }}
<compStepper1></compStepper1>
<v-card-actions>
<v-btn>SUBMIT</v-btn>
</v-card-actions>
</v-stepper-content>
</v-stepper-items>
</v-stepper>
</v-card>
</section>
</template>
<script>
import compStepper1 from "../components/compStepper1";
export default {
components: {
compStepper1
},
props: ["organization"],
data() {
return {
e1: 0
};
}
};
</script>
【问题讨论】:
-
嗨,你没有设置组件的
name——比如name: 'Document', -
尝试将
console.log(this.$options.components)放入data函数中以检查注册了哪些组件。乍一看,它似乎注册正确,但检查该对象可能有助于确认这里发生了什么。 -
@skirtle 我在尝试记录时可以看到 compStepper1
-
我的意思是让您将日志记录放在其他组件的
data函数中。查看Document是否在该对象中。
标签: javascript vue.js vuejs2 vue-component