3 回答
TA贡献1852条经验 获得超7个赞
将其包装在template标签中,因为模板标签不会出现在最终呈现的HTML中:
<template v-for="hobby in hobbies">
<input type="checkbox" v-model="userHobbies" v-bind:value="hobby">{{hobby}}
</template>
甚至更好的是,改善标记语义并使用标签标记:
<label v-for="hobby in hobbies">
<input type="checkbox" v-model="userHobbies" v-bind:value="hobby"> {{hobby}}
</label>
TA贡献1784条经验 获得超9个赞
您可以在div内添加模板,因为模板未呈现到DOM:
<div id="inputDiv">
<form action>
<input type="text" v-model="first_name">
<input type="text" v-model="last_name">
<input type="email" v-model="email">
<div>
<input type="radio" :name="gender" v-model="gender" value="male">Male
<input type="radio" :name="gender" v-model="gender" value="female">Female
</div>
<textarea v-model="address" id cols="30" rows="10"></textarea>
<br>
<template v-for="hobby in hobbies">
<input type="checkbox" v-model="userHobbies" v-bind:value="hobby">
{{hobby}}
</template>
</form>
</div>
添加回答
举报