[Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instan

来源:互联网 发布:数控加工中心编程视频 编辑:程序博客网 时间:2024/05/16 01:34

做vue的时候 ,老是有一个 warning出现,根据提示到网页看了下解决方案,因为对英语能力掌握较差,所以看来好几遍 才真正的发现自己的问题


warning如下:

 [Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instance:

在warnign下面有个链接 http://vuejs.org/guide/components.html#Fragment_Instance

点进去 我就直接找fragment instance这个关键词,ok找到问题了 

出现fragment instance有多种情况

There are multiple conditions that will turn a Vue instance into a fragment instance:

  1. Template contains multiple top-level elements. (模版包涵了多个顶级元素 说白了 你的模版元素没有唯一一个父元素)
  2. Template contains only plain text.(模版里面只包涵纯文本)
  3. Template contains only another component (which can potentially be a fragment instance itself).(模版只包含另外一个组件,而这个组件本上可以就是一个fragment instance
  4. Template contains only an element directive, e.g. <partial> or vue-router’s<router-view>.(模版只包含<partial>或者<router-view>组件 )
  5. Template root node has a flow-control directive, e.g. v-if or v-for.(模版根节点被v-if活着v-for有个逻辑判断)
其实,出现问题没什么,我们根据vue的提示链接仔细看,总能找到我们的解决方案。

另外,能吐个槽么?vue报warining的时候 要是能告诉我哪里出的 warning就好了,我可是一个一个模版翻着看呀。。。。。

0 0
原创粉丝点击