Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
ptfw-uniapp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
侯忠英
ptfw-uniapp
Commits
deb02c76
Commit
deb02c76
authored
Jul 30, 2019
by
DPFly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加基础弹窗组件
parent
68efb0e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
179 additions
and
0 deletions
+179
-0
index.vue
src/components/basic/popup/index.vue
+179
-0
No files found.
src/components/basic/popup/index.vue
0 → 100644
View file @
deb02c76
<
template
>
<block
v-if=
"visible"
>
<view
v-if=
"mask !== 'none'"
class=
"base-popup-mask"
:style=
"
{ 'background-color': mask, 'z-index': zIndex }"
@click="tapMask"
>
</view>
<view
class=
"base-popup-wrap"
:class=
"position"
:style=
"
{ 'z-index': zIndex + 1 }">
<view
class=
"base-popup"
:class=
"currClass"
:style=
"
{ transition: transition }">
<slot></slot>
</view>
</view>
</block>
</
template
>
<
script
>
const
POSITION_LIST
=
[
'center'
,
'top'
,
'bottom'
,
'left'
,
'right'
]
export
default
{
props
:
{
// 弹窗的显示与隐藏
show
:
{
type
:
Boolean
,
default
:
false
,
},
/**
* 蒙层颜色
* none - 不显示蒙层
*/
mask
:
{
type
:
String
,
default
:
'rgba(0, 0, 0, 0.6)'
,
},
// 是否点击蒙层关闭弹窗
closeOnTapMask
:
{
type
:
Boolean
,
default
:
true
,
},
/**
* 弹窗显示的位置
* 可取值:center,top,bottom,left,right
*/
position
:
{
type
:
String
,
default
:
'center'
,
validator
(
val
)
{
return
POSITION_LIST
.
includes
(
val
)
},
},
/**
* 过渡动画
* none - 无动画
*/
transition
:
{
type
:
String
,
default
:
'all 0.3s'
,
},
// 动画时间,单位毫秒(ms)
duration
:
{
type
:
Number
,
default
:
300
,
},
// 弹窗层级
zIndex
:
{
type
:
Number
,
default
:
100
,
},
},
data
()
{
return
{
visible
:
false
,
currClass
:
''
,
}
},
watch
:
{
show
:
{
handler
(
val
)
{
if
(
this
.
transition
&&
this
.
transition
!==
'none'
)
{
if
(
val
)
{
this
.
visible
=
val
this
.
currClass
=
`
${
this
.
position
}
-hidden`
this
.
$nextTick
().
then
(()
=>
{
this
.
currClass
=
`
${
this
.
position
}
-visible`
})
}
else
{
this
.
currClass
=
`
${
this
.
position
}
-hidden`
setTimeout
(()
=>
{
this
.
visible
=
val
},
this
.
duration
)
}
}
else
{
this
.
visible
=
val
}
},
immediate
:
true
,
},
},
methods
:
{
tapMask
()
{
if
(
this
.
closeOnTapMask
)
this
.
$emit
(
'update:show'
,
false
)
},
},
}
</
script
>
<
style
lang=
"scss"
scoped
>
.base-popup-mask
{
position
:
fixed
;
top
:
0
;
bottom
:
0
;
left
:
0
;
right
:
0
;
}
.base-popup-wrap
{
position
:
fixed
;
box-sizing
:
border-box
;
&
.center
{
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
}
&
.top
,
&
.bottom
{
left
:
0
;
width
:
100%
;
}
&
.top
{
top
:
0
;
}
&
.bottom
{
bottom
:
0
;
}
&
.left
,
&
.right
{
top
:
0
;
height
:
100%
;
.base-popup
{
height
:
100%
;
}
}
&
.left
{
left
:
0
;
}
&
.right
{
right
:
0
;
}
.base-popup
{
&
.center-visible
{
transform
:
scale
(
1
)
scaleZ
(
1
);
}
&
.center-hidden
{
transform
:
scale
(
0
)
scaleZ
(
1
);
}
&
.top-visible
,
&
.bottom-visible
{
transform
:
translateY
(
0
)
translateZ
(
0
);
}
&
.top-hidden
{
transform
:
translateY
(
-100%
)
translateZ
(
0
);
}
&
.bottom-hidden
{
transform
:
translateY
(
100%
)
translateZ
(
0
);
}
&
.left-visible
,
&
.right-visibl
{
transform
:
translateX
(
0
)
translateZ
(
0
);
}
&
.left-hidden
{
transform
:
translateX
(
-100%
)
translateZ
(
0
);
}
&
.right-hidden
{
transform
:
translateX
(
100%
)
translateZ
(
0
);
}
}
}
</
style
>
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