首页 > 代码库 > vue报错:[Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instance
vue报错:[Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instance
[Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instance
今天自己做一个vue小项目的时候,老是报这个错误,百度之后解释是只能有一个最顶级的父元素,但是我最外层只用了一个div
出现fragment instance有多种情况:
- Template contains multiple top-level elements. (模版包涵了多个顶级元素 说白了 你的模版元素没有唯一一个父元素)
- Template contains only plain text.(模版里面只包涵纯文本)
- Template contains only another component (which can potentially be a fragment instance itself).(模版只包含另外一个组件,而这个组件本上可以就是一个fragment instance)
- Template contains only an element directive, e.g.
<partial>
or vue-router’s<router-view>
.(模版只包含<partial>或者<router-view>组件 ) - Template root node has a flow-control directive, e.g.
v-if
orv-for
.(模版根节点被v-if活着v-for有个逻辑判断)
vue报错:[Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instance
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。