You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
892 B
31 lines
892 B
<template>
|
|
<a-cascader :load-data="loadData" :options="options" change-on-select>
|
|
<template #[item]="data" v-for="item in Object.keys($slots)" :key="item">
|
|
<slot :name="item" v-bind="data || {}"> </slot>
|
|
</template>
|
|
</a-cascader>
|
|
</template>
|
|
<script lang="ts">
|
|
import { defineComponent, ref } from 'vue';
|
|
import type { CascaderProps } from 'ant-design-vue';
|
|
export default defineComponent({
|
|
name: 'NsCascader',
|
|
setup(props, { attrs }) {
|
|
let options = ref<any[]>(attrs['options'] || []);
|
|
let loadData: CascaderProps['loadData'] | null = (selectOptions) => {
|
|
attrs['loadData'](selectOptions, options, attrs);
|
|
};
|
|
if (attrs['loadData']) {
|
|
loadData(options);
|
|
} else {
|
|
loadData = null;
|
|
}
|
|
|
|
return {
|
|
loadData,
|
|
options,
|
|
};
|
|
},
|
|
});
|
|
</script>
|
|
<style lang="less" scoped></style>
|
|
|