vue+element复选框的坑
官网写法
- 链接https://element.eleme.cn/#/zh-CN/component/checkbox
<el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
改进后可以变成竖排并且在下面加上文本框
- 只要把循环写在el-checkbox即可
<el-checkbox-group v-model="checkList">
<div v-for="item in tags" :key="item.cd">
<el-checkbox :label="item.cd" style="">
{{item.nm}}
</el-checkbox>
<el-input v-if="checkList.indexOf(item.cd)>-1"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
:placeholder="item.rmks"
v-model="item.rmks">
</el-input>
</div>
</el-checkbox-group>
<!-- tags的值[{cd:'1',nm:'jwq',rmks:'111111'},{cd:'2',nm:'zhn',rmks:'22222'}]-->