关于事件传递的坑
uni-app中传递方法
<van-swipe-cell :async-close="true" id="swipe-cell" class="swiperCell" @close="onClose" :right-width="70" >
<view class="messageInfo">
<view class="message-title-img">
<image src="https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640" mode=""></image>
</view>
<view class="message-title">
<view class="title-name">
小野猫
</view>
<view class="title-info">
你在?
</view>
</view>
</view>
<view class="deleteStyle" slot="right" data-right="right" >删除</view>
</van-swipe-cell>
onClose方法,官方的方法名字不能改
onClose(event) {
console.log(event);
const { position, instance } = event.detail;
console.log(position);
console.log(instance);
switch (position) {
case 'left':
case 'cell':
instance.close();
break;
case 'right':
uni.showModal({
title: '提示',
content: '这是一个模态弹窗',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
instance.close();
} else if (res.cancel) {
console.log('用户点击取消');
instance.close();
}
}
})
break;
}
}