<view class="grace-items">
<button @click="addItems" class="btn">添加+</button>
</view>
<view class="item" v-for="(item, index) in dataList" :key="item.id">
<button @click="del(item)" class="del-btn">-</button>
<view class="top-border bottom-border">
<textarea auto-height="true" placeholder="描述" v-model="item.remark"/>
</view>
</view>
js
data() {
return {
dataList:[
{"remark":"测试数据1"},
{"remark":"测试数据2"},
{"remark":"测试数据3"},
]
}
},
addItems(){
var a=[{"remark":"测试数据"}];
this.dataList.push(a)
},
del(e){
var index=this.selectObj.indexOf(e)
if(index!==-1){
this.dataList.splice(index,1);
}
},
2 个回复
大肥光光
var a=[{"remark":"测试数据"}];
this.dataList.push(a)
push的数据结构不对
this.dataList.push({"remark":"测试数据"}) 或者 this.dataList.push(...a)
chenli
:key 不使用index
换个唯一标识看看
7***@qq.com (作者)
换了,还是有bug
2020-11-14 10:10