【问题标题】:Vuejs import component in another componentVuejs 在另一个组件中导入组件
【发布时间】:2020-07-23 11:34:57
【问题描述】:

我创建了一个dashboard.vue 组件并将table.vue 组件导入其中,但是table.vue 没有出现在我的网页和vue.dev 工具中。

当我在 app.vue 中导入 table.vue 时没有问题。

在我的文件下面。

提前致谢!

//dashboard.vue

<template>
  <div>

  <table></table>

  </div>
</template>

<script>


import table from "./table";

 export default {
  name: 'Dashboard',
  component: {
    table, 
  }

}
</script>


<style >

</style>

//table.vue

<template>
  <div>
      <p>Test</p>

  </div>
</template>

<script>





export default {
  name: 'Table',

}
  </script>

【问题讨论】:

标签: vue.js import components


【解决方案1】:

您不能将组件命名为与保留的 HTML 元素相同的名称。将其更改为my-table

你需要映射它:

component: {
    'my-table': table, 
  }

【讨论】:

  • 我用 mytable 替换了所有表,我得到了
  • 未知自定义元素: - 您是否正确注册了组件?对于递归组件,请确保提供“名称”选项。在 ---> at src/components/Dashboard.vue at src/App.vue
  • 当我在 app.vue 中导入它时,“table”和“mytable”都没有问题
猜你喜欢
  • 2020-07-23
  • 2017-07-05
  • 1970-01-01
  • 1970-01-01
  • 2018-06-24
  • 2021-05-10
  • 2020-09-04
  • 2019-06-12
  • 2023-03-27
相关资源
最近更新 更多