Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
7a7dab0c
Commit
7a7dab0c
authored
Jul 19, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(demo): multi-modal in one page usage
添加使用is动态组件来在页面内使用多个modal的演示
parent
59eb828d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
index.vue
src/views/demo/comp/modal/index.vue
+39
-3
No files found.
src/views/demo/comp/modal/index.vue
View file @
7a7dab0c
...
...
@@ -17,6 +17,16 @@
<Alert
message=
"内外数据交互"
show-icon
/>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"send"
>
打开弹窗并传递数据
</a-button>
<Alert
message=
"使用动态组件的方式在页面内使用多个弹窗"
show-icon
/>
<a-space>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"openTargetModal(1)"
>
打开弹窗1
</a-button>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"openTargetModal(2)"
>
打开弹窗2
</a-button>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"openTargetModal(3)"
>
打开弹窗3
</a-button>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"openTargetModal(4)"
>
打开弹窗4
</a-button>
</a-space>
<component
:is=
"currentModal"
@
register=
"register"
/>
<Modal1
@
register=
"register1"
:minHeight=
"100"
/>
<Modal2
@
register=
"register2"
/>
<Modal3
@
register=
"register3"
/>
...
...
@@ -24,8 +34,8 @@
</PageWrapper>
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
Alert
}
from
'
ant-design-vue
'
;
import
{
defineComponent
,
nextTick
,
shallowRef
,
ComponentOptions
}
from
'
vue
'
;
import
{
Alert
,
Space
}
from
'
ant-design-vue
'
;
import
{
useModal
}
from
'
/@/components/Modal
'
;
import
Modal1
from
'
./Modal1.vue
'
;
import
Modal2
from
'
./Modal2.vue
'
;
...
...
@@ -34,12 +44,14 @@
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
export
default
defineComponent
({
components
:
{
Alert
,
Modal1
,
Modal2
,
Modal3
,
Modal4
,
PageWrapper
},
components
:
{
Alert
,
Modal1
,
Modal2
,
Modal3
,
Modal4
,
PageWrapper
,
ASpace
:
Space
},
setup
()
{
const
currentModal
=
shallowRef
<
Nullable
<
ComponentOptions
>>
(
null
);
const
[
register1
,
{
openModal
:
openModal1
}]
=
useModal
();
const
[
register2
,
{
openModal
:
openModal2
}]
=
useModal
();
const
[
register3
,
{
openModal
:
openModal3
}]
=
useModal
();
const
[
register4
,
{
openModal
:
openModal4
}]
=
useModal
();
const
[
register
,
{
openModal
}]
=
useModal
();
function
send
()
{
openModal4
(
true
,
{
data
:
'
content
'
,
...
...
@@ -53,6 +65,27 @@
// setModalProps({ loading: false });
// }, 2000);
}
function
openTargetModal
(
index
)
{
switch
(
index
)
{
case
1
:
currentModal
.
value
=
Modal1
;
break
;
case
2
:
currentModal
.
value
=
Modal2
;
break
;
case
3
:
currentModal
.
value
=
Modal3
;
break
;
default
:
currentModal
.
value
=
Modal4
;
break
;
}
nextTick
(()
=>
{
openModal
(
true
,
{
data
:
'
content
'
,
info
:
'
Info
'
});
});
}
return
{
register1
,
openModal1
,
...
...
@@ -62,7 +95,10 @@
openModal3
,
register4
,
openModal4
,
register
,
openTargetModal
,
send
,
currentModal
,
openModalLoading
,
};
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment