push
This commit is contained in:
31
lib/component/form/cascader/cascader.vue
Normal file
31
lib/component/form/cascader/cascader.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<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>
|
||||
5
lib/component/form/cascader/index.ts
Normal file
5
lib/component/form/cascader/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import cascader from './cascader.vue';
|
||||
|
||||
import { withInstall } from '/nerv-lib/util';
|
||||
|
||||
export const NsCascader = withInstall(cascader);
|
||||
Reference in New Issue
Block a user