<div v-if="loginType ==="username"">
<label >username</label>
<input placeholder="enter your username" key="username-input">
</div>
<div v-else>
<label>email</label>
<input placeholder="enter your email" key="email-input">
</div>
as soon as I finish writing the above code, vue-cli has the following error
./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
(Emitted value instead of an instance of Error)
Error compiling template:
<div>
<div v-if="loginType ==="username"">
<label >username</label>
<input placeholder="enter your username" key="username-input">
</div>
<div v-else-if="loginType ==="email"">
<label>email</label>
<input placeholder="enter your email" key="email-input">
</div>
</div>
<buttob @click="changed"></buttob>
- Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
@ ./src/components/DemoIf.vue 11:0-362
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js