2025-01-15 16:32:36 +08:00

116 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { RModal } from '@/components'
import { NButton, NCard, NFlex } from 'naive-ui'
import { useModal } from '@/components'
export default defineComponent({
name: 'ModalDemo',
setup() {
const state = reactive({
modal1: false,
modal2: false,
modal3: false,
})
const { create } = useModal()
const createCardModal = () => {
create({
title: '卡片模态框',
draggable: true,
preset: 'card',
content: () => (
<div style="height: 3000px;">card模态框</div>
),
fullscreen: true,
})
}
const createDialogModal = () => {
create({
title: '模态框',
content: '内容',
preset: 'dialog',
draggable: true,
})
}
return {
...toRefs(state),
createCardModal,
createDialogModal,
}
},
render() {
const { createCardModal, createDialogModal } = this
return (
<NFlex vertical>
<NCard title="props">
<NFlex vertical>
<h3>fullscreen: 全屏模态框</h3>
</NFlex>
</NCard>
<RModal
v-model:show={this.modal1}
title="全屏模态框"
fullscreen
preset="card"
>
<div style="height: 3000px;">card模态框</div>
</RModal>
<RModal
v-model:show={this.modal2}
preset="card"
title="可拖拽卡片模态框"
draggable
>
<p></p>
</RModal>
<RModal
v-model:show={this.modal3}
preset="dialog"
title="可拖拽卡片模态框"
draggable
>
<p></p>
</RModal>
<NCard title="可拖拽模态框">
<NButton onClick={() => (this.modal2 = true)}></NButton>
<NButton onClick={() => (this.modal3 = true)}></NButton>
</NCard>
<NCard title="全屏模态框">
<NFlex vertical>
<h4>
fullscreen true preset card
</h4>
<NButton onClick={() => (this.modal1 = true)}></NButton>
</NFlex>
</NCard>
<NCard title="手动设置宽度">
<h4>
width--r-modal-width: preset dialog card
</h4>
<h4>
dialogWidth--r-modal-dialog-width: preset
dialog
</h4>
<h4>
cardWidth--r-modal-card-width: preset card
</h4>
<h4>
`css variable`
</h4>
</NCard>
<NCard title="重写 useModal">
<NButton onClick={createCardModal.bind(this)}></NButton>
<NButton onClick={createDialogModal.bind(this)}>
</NButton>
</NCard>
</NFlex>
)
},
})