收藏
回答

swiper-item嵌套的t-swipe-cell为什么在真机中无法进行拖动?

wxml代码:
<view>
    </view>
    <!-- 内容布局 -->
    <swiper
        class="swiperTtemBox"
        bindchange="slideOn"
        current="{{tabsId}}"
        circular
    >
        <!-- 首页 -->
        <swiper-item skip-hidden-item-layout="{{true}}">
            <view wx:if="{{showSwiper === ''}}">
                <t-grid class="grid-block" column="{{3}}">
                    <t-grid-item text="球队" icon="member" />
                    <t-grid-item text="别名" icon="extension" />
                    <t-grid-item text="状态" icon="api" />
                </t-grid>
                <view class="container-swipe-cell">
                    <block wx:for="{{playerCell}}" wx:key="teamId">
                        <t-swipe-cell
                            right="{{right}}"
                            catchtouchmove="onSwipeTouchMove"
                            catch:click="onActionClick"
                        >
                            <view class="cell-container">
                                <view class="cell-item">
                                    <p>{{item.name}}</p>
                                </view>
                                <view class="cell-item">
                                    <p>{{item.alias}}</p>
                                </view>
                                <view class="cell-item">
                                    <t-tag
                                        wx:if="{{item.status}}"
                                        variant="light"
                                        theme="success"
                                        >进行中</t-tag
                                    >
                                    <t-tag
                                        wx:else
                                        theme="warning"
                                        variant="light"
                                        >待开始</t-tag
                                    >
                                </view>
                            </view>
                        </t-swipe-cell>
                    </block>
                </view>
    </swiper>
</view>

TS代码:
   data: {
        // 球队内容
        playerCell: [
            {
                name: "ASYS",
                alias: "asys",
                status: true,
                teamId: 1,
            },
            {
                name: "ASYS1",
                alias: "asys2",
                status: true,
                teamId: 2,
            },
        ],
        // 统计内容
        statisticsCell: [
            {
                name: "ASYS",
                alias: "asys",
                schedule: "9/10",
                teamId: 1,
            },
            {
                name: "ASYS1",
                alias: "asys2",
                schedule: "1/2",
                teamId: 2,
            },
        ],
        right: [
            {
                text: "编辑",
                icon: {
                    name: "edit",
                    size: 16,
                },
                className: "btn edit-btn",
            },
            {
                text: "开始",
                icon: {
                    name: "play",
                    size: 16,
                },
                className: "btn play-btn",
            },
        ],
        rightIcon: [
            {
                icon: "edit",
                className: "btn edit-btn",
            },
            {
                icon: "play-circle-stroke",
                className: "btn play-btn",
            },
        ],
    
    },
    methods: {
        slideOn(e: { detail: { current: any } }) {
            // 拿到当前索引并动态改变
            this.setData({
                tabsId: e.detail.current,
            });
        },
        onSwipeTouchMove: function () {
            console.log("Swiping t-swipe-cell");
            return;
        },
        tabsOn(e: { currentTarget: { dataset: { idx: any } } }) {
            this.setData({
                //拿到当前索引并动态改变
                tabsId: e.currentTarget.dataset.idx,
            });
        },
        onActionClick({ detail }: any) {
            // wx.showToast({ title: `你点击了${detail.text}` });
            if (detail.text === "开始") {
                this.setData({
                    showSwiper: "play",
                });
            } else {
                this.setData({
                    showSwiper: "edit",
                });
            }
        },
        onDelete() {
            wx.showToast({ title: "你点击了删除", icon: "none" });
        },
        onEdit() {
            wx.showToast({ title: "你点击了编辑", icon: "none" });
        },
 
    },

z昨天发现将app.josn中"componentFramework": "glass-easel",去掉后可以进行真机拖动,不确定以上代码片段有没有问题
最后一次编辑于  05-23
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容