首頁  >  問答  >  主體

無關的非props屬性(標題)傳遞給元件,但無法使用

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粉463418483P粉463418483207 天前548

全部回覆(1)我來回復

  • P粉785522400

    P粉7855224002024-03-26 09:07:41

    您應該將 inheritAttrs:false 新增到子元件:

    export default{
    inheritAttrs:false
    ...
    }
    
    

    回覆
    0
  • 取消回覆