cascader.vue 1.98 KB
<template>
    <Cascader :data="data4" :load-data="loadData"></Cascader>
</template>
<script>
    export default {
        data () {
            return {
                data4: [
                    {
                        value: 'beijing',
                        label: '北京',
                        children: [],
                        loading: false
                    },
                    {
                        value: 'hangzhou',
                        label: '杭州',
                        children: [],
                        loading:false
                    }
                ]
            }
        },
        methods: {
            loadData (item, callback) {
                item.loading = true;
                setTimeout(() => {
                    console.log(1)
                    if (item.value === 'beijing') {
                        item.children = [
//                            {
//                                value: 'talkingdata',
//                                label: 'TalkingData'
//                            },
//                            {
//                                value: 'baidu',
//                                label: '百度'
//                            },
//                            {
//                                value: 'sina',
//                                label: '新浪'
//                            }
                        ];
                    } else if (item.value === 'hangzhou') {
                        item.children = [
                            {
                                value: 'ali',
                                label: '阿里巴巴'
                            },
                            {
                                value: '163',
                                label: '网易'
                            }
                        ];
                    }
                    item.loading = false;
                    callback();
                }, 1000);
            }
        }
    }
</script>