【问题标题】:[Vue warn]: Unknown custom element: <Document>[Vue 警告]:未知的自定义元素:<Document>
【发布时间】: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


【解决方案1】:

所以,在Vue组件中,以非大写字母开头,就像html标签一样,即使你将它作为文档导入,你也应该将它作为文档使用,尝试使用

<document>

【讨论】:

猜你喜欢
  • 2018-02-06
  • 2017-12-22
  • 2019-12-14
  • 2018-01-08
  • 2019-09-22
  • 2019-07-07
  • 2021-01-01
  • 2018-04-08
  • 2018-09-14
相关资源
最近更新 更多