1 Star 0 Fork 0

GGB/vue2+tsx-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
VbenModal.vue 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
<template>
<Modal v-bind="getBindValue" v-on="$listeners" @cancel="onCancel">
<slot></slot>
<template #[item]="data" v-for="item in Object.keys(omit($slots, 'default'))">
<slot :name="item" v-bind="data || {}"></slot>
</template>
</Modal>
</template>
<script lang="ts">
/**
* 该组件用于处理Modal.tsx 属性绑定无效的bug 而新建的组件
*/
import { Modal } from 'ant-design-vue'
import { computed, defineComponent, ref, toRefs, unref } from 'vue'
import { basicProps } from '../props'
import { useModalDragMove } from '../hooks/useModalDrag'
import { useAttrs } from '/@/hooks/core/useAttrs'
import { ModalProps } from '../typing'
import { omit } from 'lodash-es'
export default defineComponent({
name: 'VModal',
inheritAttrs: false,
props: basicProps,
emits: ['cancel'],
components: { Modal },
setup(props, { emit }) {
const propsRef = ref<Partial<ModalProps> | null>(null)
const { visible, draggable, destroyOnClose } = toRefs(props)
const attrs = useAttrs()
useModalDragMove({
visible,
destroyOnClose,
draggable,
})
const onCancel = (e: Event) => {
emit('cancel', e)
}
// Custom title component: get title
const getMergeProps = computed((): Recordable => {
return {
...omit(props, 'draggable'),
...(unref(propsRef) as any),
}
})
const getBindValue = computed((): Recordable => {
const attr = {
...attrs,
...unref(getMergeProps),
}
return attr
})
return { getBindValue, onCancel, omit }
},
})
</script>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ggbhack/vue2-tsx-testv.git
git@gitee.com:ggbhack/vue2-tsx-testv.git
ggbhack
vue2-tsx-testv
vue2+tsx-test
master

搜索帮助