微信小程序 list.splice移除一个值后,赋值成功, 但是页面无刷新?
1、js删除函数:可以成功删除
deletePerson: function (e) {
var arr = this.data.PersonArray;
var index = e.currentTarget.dataset.index;
arr.splice(index, 1)
this.setData({
PersonArray: arr,
});
console.log("删除一个员工后,所有员工信息:", this.data.PersonArray)// 打印显示,成功删除了index下标的数据
},
2、但是页面无法刷新 <!-- 员工管理 -->
<view class="item">
<view class="title">
<view>员工管理 :</view>
</view>
<view wx:for="{{PersonArray}}" wx:for-item="person" wx:for-index="index" wx:key="this">
<view class="health-card">
<!-- 删除一个员工 -->
<view class="delete_person">
<view class="delete_person num">序号 {{index+1}}</view>
<view class="delete_person txt" hover-class='highSelectColor' data-index="{{index}}" bindtap="deletePerson">
<image class="delete_person icon" src="../../resource/删除.png"> </image>
<text>删除</text>
</view>
</view>
<!-- 员工姓名 -->
<view class="person">
<text class="title">员工姓名:</text>
<input class="con" maxlength="15" data-index="{{index}}" bindinput="getPersonName" placeholder="请输入..." />
</view>
<!-- 岗位名称 -->
<view class="person">
<text class="title">岗位名称:</text>
<input type="text" class="con" data-index="{{index}}" bindinput="getPersonPost" placeholder="请输入..." />
</view>
<!-- 联系电话 -->
<view class="person">
<text class="title">联系电话:</text>
<input type="number" class="con" data-index="{{index}}" bindinput="getPersonPhone" placeholder="请输入..." />
</view>
</view>
</view>
<!-- 添加一个员工 -->
<view class="add" hover-class='highSelectColor' bindtap="addOnePerson">
<image class="add-person" src="../../resource/添加.png"></image>
<text>添加员工</text>
</view>
</view>