Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit b77b5ca

Browse files
sugar258596Tang
andauthored
feat: Dialog类型的Modal (#345)
Co-authored-by: Tang <[email protected]>
1 parent 2e7000b commit b77b5ca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/demo/src/Modal/index.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ import { ref } from 'vue';
44
let alertInfo = ref('这个模态框本质是一个弹出的遮罩层,在遮罩层里你可以定义任意类型的 Card, Dialog, 或者不定义😶‍🌫️, Vben并没有封装默认的类型,所以你可以根据自己的实际业务定制😋')
55
let defaultModalShow = ref(false)
66
let isModalShow = ref(false)
7+
let dialogModalShow = ref(false)
78
const cTitle = ref('这个模态框里装了一个卡片📇')
89
const cContent = ref('🚧山重水复疑无路🚧')
910
const aTitle = ref('Card类型的Modal')
1011
const bTitle = ref("默认的Modal")
1112
const dTitle = ref('Dialog类型的Modal')
13+
const dialogTitle = ref('Dialog类型的Modal的标题')
14+
const dialogContent = ref('你确认?')
15+
const dialogPositiveText = ref('确认')
16+
const dialogNegativeText = ref('算了')
17+
18+
//关闭 dialogModalShow
19+
function CloseDialog() {
20+
dialogModalShow.value = !dialogModalShow.value
21+
}
1222
1323
</script>
1424

25+
1526
<template>
1627
<div class="m-2 grid grid-cols-12 gap-4">
1728
<div class="col-start-1 col-span-8">
@@ -30,7 +41,7 @@ const dTitle = ref('Dialog类型的Modal')
3041

3142
<div class="col-start-7 col-span-3">
3243
<VbenCard :title="dTitle">
33-
<VbenButton>点我</VbenButton>
44+
<VbenButton @click="dialogModalShow = true">点我</VbenButton>
3445
</VbenCard>
3546
</div>
3647

@@ -42,6 +53,11 @@ const dTitle = ref('Dialog类型的Modal')
4253
<VbenCard class="w-1/2" :title="cTitle" role="dialog">{{ cContent }}</VbenCard>
4354
</VbenModal>
4455

56+
<VbenModal v-model:show="dialogModalShow" @PositiveClick="CloseDialog" :title="dialogTitle" @maskClick="CloseDialog"
57+
@NegativeClick="CloseDialog" :content="dialogContent" :positive-text="dialogPositiveText"
58+
:negative-text="dialogNegativeText" preset="dialog">
59+
</VbenModal>
60+
4561
</div>
4662
</template>
4763

0 commit comments

Comments
 (0)