form设计批量赋值
data: { list:[], cards: { cardname: "", cardtitle: "", cardtel: "", cardcomp: "", degsin: '', remarks:''} },
// 名字赋值 changCardsFn(e) { let key = e.currentTarget.dataset.key; this.data.cards[key] = e.detail.value; this.setData({ cards: this.data.cards }); },
<view class="form-item flex"> <view class="item-lf">姓名</view> <view class="item-rt"> <input class="rt-input h" name="cardname" data-key="cardname" maxlength="{{20}}" value="{{cards.cardname}}" placeholder="请填写名字" bindinput="changCardsFn"></input> </view> </view> <view class="form-item flex"> <view class="item-lf">职业</view> <view class="item-rt"> <input class="rt-input h" name="cardtitle" data-key="cardtitle" maxlength="{{20}}" value="{{cards.cardtitle}}" placeholder="请填写职业" bindinput="changCardsFn"></input> </view> </view>