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
f732b569
Commit
f732b569
authored
Jun 02, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(modal): add redoModalHeight for useModalInner
允许在Modal内部动态加载内容后重新调整高度
parent
9e2aa20d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
13 deletions
+58
-13
useModal.ts
src/components/Modal/src/hooks/useModal.ts
+5
-0
types.ts
src/components/Modal/src/types.ts
+1
-0
Modal1.vue
src/views/demo/comp/modal/Modal1.vue
+43
-4
index.vue
src/views/demo/comp/modal/index.vue
+9
-9
No files found.
src/components/Modal/src/hooks/useModal.ts
View file @
f732b569
...
...
@@ -150,6 +150,11 @@ export const useModalInner = (callbackFn?: Fn): UseModalInnerReturnType => {
setModalProps
:
(
props
:
Partial
<
ModalProps
>
)
=>
{
getInstance
()?.
setModalProps
(
props
);
},
redoModalHeight
:
()
=>
{
const
callRedo
=
getInstance
()?.
redoModalHeight
;
callRedo
&&
callRedo
();
},
},
];
};
src/components/Modal/src/types.ts
View file @
f732b569
...
...
@@ -23,6 +23,7 @@ export interface ReturnInnerMethods extends ModalMethods {
changeLoading
:
(
loading
:
boolean
)
=>
void
;
changeOkLoading
:
(
loading
:
boolean
)
=>
void
;
getVisible
?:
ComputedRef
<
boolean
>
;
redoModalHeight
:
()
=>
void
;
}
export
type
UseModalInnerReturnType
=
[
RegisterFn
,
ReturnInnerMethods
];
...
...
src/views/demo/comp/modal/Modal1.vue
View file @
f732b569
<
template
>
<BasicModal
v-bind=
"$attrs"
title=
"Modal Title"
:helpMessage=
"['提示1', '提示2']"
>
Modal Info.
<BasicModal
v-bind=
"$attrs"
destroyOnClose
@
register=
"register"
title=
"Modal Title"
:helpMessage=
"['提示1', '提示2']"
@
visible-change=
"handleShow"
>
<template
v-if=
"loading"
>
<div
class=
"empty-tips"
>
加载中,稍等3秒……
</div>
</
template
>
<
template
v-if=
"!loading"
>
<ul>
<li
v-for=
"index in lines"
:key=
"index"
>
加载完成
{{
index
}}
!
</li>
</ul>
</
template
>
</BasicModal>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
BasicModal
}
from
'
/@/components/Modal
'
;
import
{
defineComponent
,
ref
}
from
'
vue
'
;
import
{
BasicModal
,
useModalInner
}
from
'
/@/components/Modal
'
;
export
default
defineComponent
({
components
:
{
BasicModal
},
setup
()
{
const
loading
=
ref
(
true
);
const
lines
=
ref
(
10
);
const
[
register
,
{
setModalProps
,
redoModalHeight
}]
=
useModalInner
();
function
handleShow
(
visible
:
boolean
)
{
if
(
visible
)
{
loading
.
value
=
true
;
setModalProps
({
loading
:
true
});
setTimeout
(()
=>
{
lines
.
value
=
Math
.
round
(
Math
.
random
()
*
20
+
10
);
loading
.
value
=
false
;
setModalProps
({
loading
:
false
});
redoModalHeight
();
},
3000
);
}
}
return
{
register
,
loading
,
handleShow
,
lines
};
},
});
</
script
>
<
style
scoped
>
.empty-tips
{
height
:
100px
;
line-height
:
100px
;
text-align
:
center
;
}
</
style
>
src/views/demo/comp/modal/index.vue
View file @
f732b569
...
...
@@ -2,11 +2,11 @@
<PageWrapper
title=
"modal组件使用示例"
>
<Alert
message=
"使用 useModal 进行弹窗操作,默认可以拖动,可以通过 draggable
参数进行控制是否可以拖动/全屏"
参数进行控制是否可以拖动/全屏
,并演示了在Modal内动态加载内容并自动调整高度
"
show-icon
/>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"openModalLoading"
>
打开弹窗
默认可以拖动/全屏
打开弹窗
,加载动态数据并自动调整高度(默认可以拖动/全屏)
</a-button>
<Alert
message=
"内外同时同时显示隐藏"
show-icon
/>
...
...
@@ -20,7 +20,7 @@
/>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"send"
>
打开弹窗并传递数据
</a-button>
<Modal1
@
register=
"register1"
/>
<Modal1
@
register=
"register1"
:minHeight=
"100"
/>
<Modal2
@
register=
"register2"
/>
<Modal3
@
register=
"register3"
/>
<Modal4
@
register=
"register4"
/>
...
...
@@ -39,7 +39,7 @@
export
default
defineComponent
({
components
:
{
Alert
,
Modal1
,
Modal2
,
Modal3
,
Modal4
,
PageWrapper
},
setup
()
{
const
[
register1
,
{
openModal
:
openModal1
,
setModalProps
}]
=
useModal
();
const
[
register1
,
{
openModal
:
openModal1
}]
=
useModal
();
const
[
register2
,
{
openModal
:
openModal2
}]
=
useModal
();
const
[
register3
,
{
openModal
:
openModal3
}]
=
useModal
();
const
[
register4
,
{
openModal
:
openModal4
}]
=
useModal
();
...
...
@@ -50,11 +50,11 @@
});
}
function
openModalLoading
()
{
openModal1
();
setModalProps
({
loading
:
true
});
setTimeout
(()
=>
{
setModalProps
({
loading
:
false
});
},
2000
);
openModal1
(
true
);
//
setModalProps({ loading: true });
//
setTimeout(() => {
//
setModalProps({ loading: false });
//
}, 2000);
}
return
{
register1
,
...
...
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