无关的非props属性(标题)被传递给组件,但无法使用
P粉463418483
P粉463418483 2024-03-25 20:03:46
0
1
541

runtime-core.esm-bundler.js?d2dd:38 [Vue warn]: Extraneous non-props attributes (title) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. 
  at <ProductTable title="Product List" > 
  at <Home onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > > 
  at <RouterView> 
  at <App>

这是我在 Vue 应用程序的 chrome 控制台中遇到的错误。下面是我的父视图组件。我正在尝试向其中添加多个组件,例如主页内容和页脚。

<template>
  <div class="home">
    <ProductTable title="Product List"/>
    <Footer title="I am the child"/>
  </div>
</template>

<script>
import ProductTable from '@/components/ProductTable.vue'
import Footer from '@/components/Footer.vue'
import Functions from '@/components/ProductListFunctions.js'


export default {
  name: 'Home',
  components: {
    ProductTable,
    Footer
  }
}
</script>

感谢任何帮助,因为我无法弄清楚。该错误只是一个警告,不会影响任何页面。但如果离开就好了。干杯。

P粉463418483
P粉463418483

全部回复(1)
P粉785522400

您应该将 inheritAttrs:false 添加到子组件:

export default{
inheritAttrs:false
...
}

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!