<block wx:for="{{fenleilist}}" wx:key=“idx” wx:for-index=“idx” wx:for-item=“data”>
<view class=‘itemlist’>
<view class=‘title’><input type=“text” maxlength=“30” confirm-type=“done” bindconfirm=“save_fenlei” value="{{data.title}}" placeholder=“填写店铺分类名称” /> </view>
<view class=‘bianji’> <button size=“mini” type=“primary”>编辑</button> </view>
<view class=‘del’> <icon type=“clear” bindtap=‘del_fenlei’ data-index=’{{idx}}’ data-fenlei_id=’{{data.id}}’ size=“23”/> </view>
</view>
</block>
<view class=‘anniu’ > <button bindtap=‘add_fenlei’ size=“default” type=“primary”>添加店铺分类</button> </view>
data: {
fenleilist:[]
},
add_fenlei:function(e){
var that = this
const length = that.data.fenleilist.length
that.data.fenleilist = [{ id: length, title: ‘title_’ + length }].concat(that.data.fenleilist)
that.setData({
fenleilist: that.data.fenleilist
})
},
del_fenlei:function(e){
var that = this
var fenlei_id = e.currentTarget.dataset.fenlei_id;
var index = e.currentTarget.dataset.index;
var fenlei = that.data.fenleilist;
console.log(fenlei.splice(index, 1))
that.setData({
fenleilist: fenlei.splice(index,1)
})
},