猿问

vue中v-if出现的问题

我写完上面的代码后,vue-cli马上出现下面的错误
./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-f68cdee0","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/components/DemoIf.vue
(EmittedvalueinsteadofaninstanceofError)
Errorcompilingtemplate:
-Componenttemplateshouldcontainexactlyonerootelement.Ifyouareusingv-ifonmultipleelements,usev-else-iftochaintheminstead.
@./src/components/DemoIf.vue11:0-362
@./src/router/index.js
@./src/main.js
@multi(webpack)-dev-server/client?http://localhost:8080webpack/hot/dev-server./src/main.js

		
森栏
浏览 1661回答 2
2回答

桃花长相依

Componenttemplateshouldcontainexactlyonerootelement.Ifyouareusingv-ifonmultipleelements,usev-else-iftochaintheminstead.组件模板应该只包含一个根元素组件内容

手掌心

楼上说了,template里面只能有一个根元素........改成........
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答