Vue3报错:Extraneous non-props attributes (style) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.

翻译是:无关的非道具属性(样式)被传递给组件,但由于组件呈现片段或文本根节点而无法自动继承。

出现这个错误的原因是在组件的节点上添加了样式,也就是

<组件 style='display:none'></组件>

我本来的思路是想让这个组件隐藏起来的,但这样行不通

所以解决办法就是在组件外套一层div,即

<div style='display:none'>
	<组件></组件>
</div>
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐