-
zhangwei
2025-03-05 16213c0f85aa3ac8317797bf4a05fd12940e16d3
src/uni_modules/uview-plus/components/u-waterfall/u-waterfall.vue
@@ -67,11 +67,16 @@
        },
        watch: {
            copyFlowList(nVal, oVal) {
                // 取差值,即这一次数组变化新增的部分
                let startIndex = Array.isArray(oVal) && oVal.length > 0 ? oVal.length : 0;
                // 拼接上原有数据
                this.tempList = this.tempList.concat(this.cloneData(nVal.slice(startIndex)));
                this.splitData();
                if (!nVal || nVal.length == 0) {
                    this.clear(false);
                    // console.log('clear');
                } else {
                    // 取差值,即这一次数组变化新增的部分
                    let startIndex = Array.isArray(oVal) && oVal.length > 0 ? oVal.length : 0;
                    // 拼接上原有数据
                    this.tempList = this.tempList.concat(this.cloneData(nVal.slice(startIndex)));
                    this.splitData();
                }
            }
        },
        mounted() {
@@ -81,11 +86,17 @@
        computed: {
            // 破坏flowList变量的引用,否则watch的结果新旧值是一样的
            copyFlowList() {
                // #ifdef VUE3
                if (!this.modelValue || this.modelValue.length == 0) {
                    this.clear(false);
                    // console.log('clear');
                    return [];
                } else {
                    return this.cloneData(this.modelValue);
                }
                // #endif
                // #ifdef VUE2
                return this.cloneData(this.value);
                // #endif
                // #ifdef VUE3
                return this.cloneData(this.modelValue);
                // #endif
            }
        },
@@ -127,16 +138,18 @@
                return JSON.parse(JSON.stringify(data));
            },
            // 清空数据列表
            clear() {
            clear(bak = true) {
                this.leftList = [];
                this.rightList = [];
                // 同时清除父组件列表中的数据
                // #ifdef VUE2
                this.$emit('input', []);
                // #endif
                // #ifdef VUE3
                this.$emit('update:modelValue', []);
                // #endif
                if (bak) {
                    // #ifdef VUE2
                    this.$emit('input', []);
                    // #endif
                    // #ifdef VUE3
                    this.$emit('update:modelValue', []);
                    // #endif
                }
                this.tempList = [];
            },
            // 清除某一条指定的数据,根据id实现
@@ -230,4 +243,4 @@
        max-width: 100%;
        /* #endif */
    }
</style>
</style>