Skip to content

Commit 24a2887

Browse files
committed
useFaModal 示例扩充
1 parent 81b4cab commit 24a2887

File tree

1 file changed

+14
-4
lines changed
  • src/views/component_built_in_example

1 file changed

+14
-4
lines changed

src/views/component_built_in_example/modal.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,25 @@ function showModalPromiseConfirm() {
138138
}
139139
140140
const TestComponent = defineComponent({
141-
setup() {
141+
props: {
142+
close: {
143+
type: Function,
144+
},
145+
},
146+
setup(props) {
142147
const val = ref('123')
143148
return () => (
144-
<div>
149+
<div class="flex flex-col gap-4">
145150
<input v-model={val.value} class="w-full border rounded-md p-2" />
151+
<fa-button onClick={() => props.close?.()}>
152+
组件内部关闭弹窗
153+
</fa-button>
146154
</div>
147155
)
148156
},
149157
})
150158
151-
const { open: open2 } = useFaModal().create({
159+
const { open: open2, close: close2 } = useFaModal().create({
152160
title: '标题',
153161
description: '这里是一段描述介绍',
154162
beforeClose: (action, done) => {
@@ -165,7 +173,9 @@ const { open: open2 } = useFaModal().create({
165173
done()
166174
}
167175
},
168-
content: h(TestComponent),
176+
content: h(TestComponent, {
177+
close: () => close2(),
178+
}),
169179
})
170180
</script>
171181

0 commit comments

Comments
 (0)