在使用vue的時(shí)候經(jīng)常會(huì)出現(xiàn)一些小的錯(cuò)誤,記錄下來舔清。
[Vue warn]: Attribute "id" is ignored on component <div> because the component is a fragment instanc
這個(gè)提示的原因是使用 vue-router 和 vue-loader 插件的時(shí)候在最外面那個(gè) template 里面炫彩,所有內(nèi)容的外面沒有使用一個(gè)div包起來注祖。
如果沒有使用div或者其他的元素包起來,vue-router 跳轉(zhuǎn)時(shí),vue不知道要?jiǎng)h除哪些東西斋陪,所以才會(huì)報(bào)錯(cuò)。
Template contains multiple top-level elements.
(模版包涵了多個(gè)頂級(jí)元素置吓,模版元素沒有唯一一個(gè)父元素)
Template contains only plain text.
(模版里面只包涵純文本)
Template contains only another component (which can potentially be a fragment instance itself).
模版只包含另外一個(gè)組件无虚,而這個(gè)組件本上可以就是一個(gè)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 or v-for.
(模版根節(jié)點(diǎn)被v-if活著v-for有個(gè)邏輯判斷)
參考鏈接