标签 滑动单元格 下的文章

SwipeCell 滑动单元格的demo,官方并没有给出一个可以使用的demo。只是说用小程序的selectComponent来获取到当前组件,然后就可以调用open与close事件了。

WXML如下

<block wx:for="{{list}}" wx:key="index">
    <van-swipe-cell right-width="{{ 120 }}" id="swipe-{{index}}">
        <view class="station-list wd">
            <view class="station-list-top">
                <text>{{item.jobName}}</text>
            </view>
            <view class="station-list-bottom">
                <text>{{item.recruitmentSubjectName}}</text>
            </view>
            <view class="more" bindtap="swipeOpen" data-index="{{index}}">
                <text class="iconfont icongengduo"></text>
            </view>
        </view>
        <view slot="right" class="right-bottom">
            <view class="right-edit">修改</view>
            <view class="right-del">删除</view>
        </view>
    </van-swipe-cell>
</block>

JS如下

swipeOpen(e){
    let index = e.currentTarget.dataset.index
    this.selectComponent('#swipe-'+index).open('right');
}

这样用的话,并不会报错。但是无论怎么样都是不能让它滑动打开的。

- 阅读剩余部分 -