climblee / uv-ui

uv-ui 破釜沉舟之兼容vue3+2、app、h5、小程序等多端基于uni-app和uView2.x的生态框架,支持单独导入,开箱即用,利剑出击。
MIT License
726 stars 34 forks source link

滑动单元,删除item的时候,报错,且更新列表后点击了列表更新后,当前位置的元素 #23

Closed qwqetyrtue closed 11 months ago

qwqetyrtue commented 11 months ago

这个一个会话列表

<uni-swipe-action>
    <block v-for="(item, index) in topList" :key="item.jid">
        <free-media-list :item="item" :index="index" isTop></free-media-list>
    </block>
    <block v-for="(item, index) in normalList" :key="item.jid">
        <free-media-list :item="item" :index="index"></free-media-list>
    </block>
</uni-swipe-action>

这是组件free-media-list

<template>
    <uni-swipe-action-item :right-options="options" @click="onOption">
        <!-- 内部的代码......  -->
    </uni-swipe-action-item>
</template>
<script>
    export default {
        data(){
            return {
                options: [{
                    name: "delete",
                    text: '删除',
                    style: {
                        backgroundColor: '#ff596a'
                    }
                }]
            }
        },
                methods: {
                    onOption(e){
                console.log(e)
                let cmd = e.content.name
                if( cmd == 'delete'){
                    // 执行删除操作
                    ......
                    //
                }
            },
                }
    }
</script>

使用uni-swipe-action尝试删除一个元素时,报错,且会点击删除元素后,被顶到原来位置的元素

Snipaste_2023-10-12_12-02-36

修改代码,延时,后就行了

if( cmd == 'delete'){
console.log("删除会话")
setTimeout(() => {
// 执行删除操作
......
//
}, 500)
}

感觉是删除方法执行后,更新了list,然后元素没了,但是收回动画还没完,延时让他收回完再删除就没事了,希望能出个事件,监听收回动画完成

climblee commented 11 months ago

你这是uni-ui的组件,走错片场啦

qwqetyrtue commented 11 months ago

尴尬了,我去换你们的组件试试