Skip to content

When cascader obtains data through load-data, the load-data method will not be executed when the default value is initialized. #4985

@menkeydyvh

Description

@menkeydyvh

Version

3.0.0-alpha.14

Reproduction link

https://next.antdv.com/components/cascader-cn#API

Steps to reproduce

简略代码

<template>
    <a-cascader
        v-model:value="data"
        :options="options"
        :load-data="loadData"
        placeholder="Please select"
    />
    {{ data }}
</template>
<script>
import { defineComponent, ref } from "vue";
export default defineComponent({
    components: {},
    setup() {
        const data = ref(["1", "1-1"]),
            options = ref([
                {
                    value: '1',
                    label: 'Zhejiang1',
                    isLeaf: false,
                }
            ]);
        const loadData = (selectedOptions) => {
            const targetOption = selectedOptions[selectedOptions.length - 1];
            targetOption.loading = true;
            setTimeout(() => {
                targetOption.loading = false;
                targetOption.children = [{
                    value: `${targetOption.value}-1`,
                    label: `${targetOption.label}-下级1`,
                }, {
                    value: `${targetOption.value}-2`,
                    label: `${targetOption.label}-下级2`,
                }];
            }, 1000);
        }

        return {
            options,
            data,
            loadData,
        };
    },
});
</script>

已知存在data = ref(["1", "1-1"]) 的数据值。
当这个值为初始化赋值的时

What is expected?

控件应当在初始化时 帮忙执行loadData来形成完整options的数据链
image

What is actually happening?

无任何触发执行且数据链无法完整显示
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions