[Vue warn]: Extraneous non-props attributes (highlight-current-row, stripe, row-class-name) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
产生问题复现流程:
这是一个自己封装的table组件,在组件内需要根据changeTab来显隐这个table,但是在隐藏这个table的时候,外部传递进来的props属性无法被继承,所以报了这个警告。
怎么解决这个警告
百度搜索了一下 链接超多 都没办法解决,让我在外面加div 也没办法解决
以下是问ai,ai回复我的
这个问题是由于你在组件中传递了一些非 props 属性,但由于组件渲染的是片段或文本根节点,这些属性无法自动继承。要解决这个警告,你可以使用 v-bind
指令将这些属性绑定到组件的 props 上,或者在组件中使用 $attrs
属性来接收这些非 props 属性
基本上和我分析的差不多。
最后在自己的外层加了一个div用来保存外部传递进来的props属性