2022-10-27 16:55

VUE3常见错误大全

王姐姐

WEB前端

(1042)

(0)

收藏

1 Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.

无关的非道具属性(类)被传递给组件,但不能被自动继承,因为组件呈现片段或文本根节点。

首先检查是否传递了没有解析的属性,可以检查一下你用的第三方的组件,或者自己编写的组件,是否 存在没有解析的属性,例如:class等属性

其次,还有一个重要原因是组件呈现片段或文本根节点,即组件暴露在了最外层。也就是vue内置或封装的组件、使用的第三方组件是否直接放在了template下。外面套一层div即可解决。

2 Component inside <Transition> renders non-element root node that cannot be animated 

在Vue3 + TS项目中点击一个页面是可以显示页面内容的,但离开当前页点击其他页面是出现白屏问题,控制台提示 Component inside <Transition> renders non-element root node that cannot be animated

检查代码后是未包裹组件的问题,只需要使用div将组件包裹起来即可。

<template>
  <div> 
     组件
 </div>
</template>



0条评论

点击登录参与评论