restructure/src/components/Modal/index.vue

48 lines
876 B
Vue
Raw Normal View History

2022-05-24 09:09:30 +08:00
<template>
2022-05-24 09:20:29 +08:00
<n-modal v-bind="getModalOptions" preset="dialog">
2022-05-24 09:09:30 +08:00
<n-card>
<slot name="Context" />
</n-card>
</n-modal>
</template>
<script>
2022-05-24 09:20:29 +08:00
import { defineComponent, computed, unref } from 'vue'
2022-05-24 09:09:30 +08:00
export default defineComponent({
name: 'ModalModules',
props: {
2022-05-24 09:20:29 +08:00
options: {
type: Object,
default: () => {}
2022-05-24 09:09:30 +08:00
}
},
emits: {
click: null, // click事件没有检验
onClose: (value) => {
return value
}
},
setup(props, { emit }) {
const getModalOptions = computed(() => {
2022-05-24 09:20:29 +08:00
return unref(props.options)
2022-05-24 09:09:30 +08:00
})
2022-05-24 09:20:29 +08:00
console.log(getModalOptions)
2022-05-24 09:09:30 +08:00
const handleClick = function() {
emit('click')
}
const handleCancel = function() {
emit('onClose', true)
}
return {
getModalOptions,
handleClick,
handleCancel
}
}
})
</script>
<style scoped lang='scss'>
</style>