案例:
主页代码:
html
<view style="margin-top: 20rpx;">
<view style="position: relative;">
<view class="textAlignCenter namedandu color-1777ff fontBold fontSize36">教育经历</view>
<view bindtap="goJiaoYu" class="jiahao">+</view>
<view class="clearBoth"></view>
</view>
<view wx:for="{
{jiaoYuJingLiList}}" wx:key="index" class="lianxirenListB fontSize30">
<view class="itemtB">
<view>起止时间:{
{item.begindate}}至{
{item.enddate}}</view>
<view>学校名称:{
{item.school}}</view>
<view>专业:{
{item.major}}</view>
</view>
<view style="flex-direction:column-reverse;" class="itemtB color-1777ff">
<view bind:tap="shanChu" data-name="jiaoYuJingLiList" data-index="{
{index}}">删除</view>
<view bind:tap="goJiaoYu" data-item="{
{item}}" data-index="{
{index}}">修改</view>
</view>
</view>
</view>
js:
goJiaoYu(e){
var that=this;
wx.navigateTo({
url: './jiaoYuJingLi/jiaoYuJingLi',
success: (res) => {
res.eventChannel.emit('delivery', {
index: e.currentTarget.dataset.index,
item: e.currentTarget.dataset.item?e.currentTarget.dataset.item:'',
jiaoYuJingLiList: that.data.jiaoYuJingLiList
})
}
})
},
//删除
shanChu(e){
var that=this;
let index = e.currentTarget.dataset.index;
let name = e.currentTarget.dataset.name;
wx.showModal({
title: '提示',
content: '请确认是否删除?',
success: (res) => {
if (res.confirm) {
let newn = that.data[name];
newn.splice(index, 1)
that.setData({
[name]: newn
})
}
}
})
},
列表页面:
html:
<!--subPackageA/pages/ruZhiDengJi/jiaoYuJingLi/jiaoYuJingLi.wxml-->
<view style="margin-bottom: 20rpx;" class="fontSize34">
<view class="refuel-item">
<text