This repository was archived by the owner on Jan 9, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +81
-7
lines changed
Expand file tree Collapse file tree 2 files changed +81
-7
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ Next create your Dialog component that will be launched from method. Name it Inf
3939</GDialog >
4040```
4141
42+ ))) method-switch
43+
44+ ::: vue-slot composition
4245``` js
4346// InfoDialog.vue
4447import { computed } from ' vue'
@@ -49,13 +52,11 @@ export default {
4952 components: {
5053 GDialog,
5154 },
52-
5355 props: {
5456 modelValue: {
5557 type: Boolean ,
5658 default: false ,
5759 },
58-
5960 info: {
6061 type: String ,
6162 required: true ,
@@ -79,9 +80,79 @@ export default {
7980 },
8081}
8182```
83+ :::
84+
85+ ::: vue-slot option
86+ ``` js
87+ // InfoDialog.vue
88+ import { GDialog } from ' gitart-vue-dialog'
89+
90+ export default {
91+ name: ' BaseDialog' ,
92+ components: {
93+ GDialog,
94+ },
95+ props: {
96+ modelValue: {
97+ type: Boolean ,
98+ default: false ,
99+ },
100+ info: {
101+ type: String ,
102+ required: true ,
103+ },
104+ },
105+
106+ computed: {
107+ value: {
108+ get () {
109+ return this .modelValue
110+ },
111+ set (val ) {
112+ this .$emit (' update:modelValue' , val)
113+ },
114+ },
115+ },
116+ }
117+ ```
118+ :::
119+
120+ )))
121+
82122
83123Now launch the dialog from any component of your app:
84124
125+ ))) method-switch
126+
127+ ::: vue-slot composition
128+ ``` js
129+ import { dialogInjectionKey } from ' gitart-vue-dialog'
130+ const InfoDialog = defineAsyncComponent (() => import (' @/components/InfoDialog.vue' ))
131+
132+ export default {
133+ setup () {
134+ const {
135+ addDialog ,
136+ } = inject (dialogInjectionKey)
137+
138+ const onOpenInfo = () => {
139+ addDialog ({
140+ component: InfoDialog,
141+ props: {
142+ info: ' Info to display' ,
143+ },
144+ })
145+ }
146+
147+ return {
148+ onOpenInfo,
149+ }
150+ },
151+ }
152+ ```
153+ :::
154+
155+ ::: vue-slot option
85156``` js
86157const InfoDialog = defineAsyncComponent (() => import (' @/components/InfoDialog.vue' ))
87158
@@ -97,4 +168,7 @@ export default {
97168 },
98169 },
99170}
100- ```
171+ ```
172+ :::
173+
174+ )))
Original file line number Diff line number Diff line change 11<template >
22 <Component
3- :is =" modal .component"
4- v-for =" (modal , index) in dialogs"
5- :key =" modal .id"
6- v-bind =" modal .props"
3+ :is =" dialog .component"
4+ v-for =" (dialog , index) in dialogs"
5+ :key =" dialog .id"
6+ v-bind =" dialog .props"
77 @update:modelValue =" onClose(index)"
88 />
99</template >
You can’t perform that action at this time.
0 commit comments