Skip to content

Commit 3ed4592

Browse files
committed
fix: 修复popup 显示错误
1 parent 3c72248 commit 3ed4592

6 files changed

Lines changed: 383 additions & 348 deletions

File tree

‎.editorconfig‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
# all files
6+
[*]
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 4
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
# md files
15+
[*.md]
16+
insert_final_newline = false
17+
trim_trailing_whitespace = false

‎components/uni-grid/uni-grid.vue‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@
8484
}
8585
</script>
8686

87-
<style lang="scss" scoped>
87+
<style>
88+
@charset "UTF-8";
89+
8890
.uni-grid {
8991
display: flex;
9092
flex-wrap: wrap;
9193
box-sizing: border-box;
92-
border-left: 1px #d0dee5 solid;
94+
border-left: 1px #d0dee5 solid
9395
}
9496
</style>

‎components/uni-popup/uni-popup.vue‎

Lines changed: 186 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,187 @@
1-
<template>
2-
<view v-if="show" class="uni-popup">
3-
<view :class="[ani, animation ? 'ani' : '', !custom ? 'uni-custom' : '']" class="uni-popup__mask" @click="close(true)" />
4-
<view :class="[type, ani, animation ? 'ani' : '', !custom ? 'uni-custom' : '']" class="uni-popup__wrapper" @click="close(true)">
5-
<view class="uni-popup__wrapper-box" @click.stop="clear">
6-
<slot />
7-
</view>
8-
</view>
9-
</view>
10-
</template>
11-
12-
<script>
13-
export default {
14-
name: 'UniPopup',
15-
props: {
16-
// 开启动画
17-
animation: {
18-
type: Boolean,
19-
default: true
20-
},
21-
// 弹出层类型,可选值,top: 顶部弹出层;bottom:底部弹出层;center:全屏弹出层
22-
type: {
23-
type: String,
24-
default: 'center'
25-
},
26-
// 是否开启自定义
27-
custom: {
28-
type: Boolean,
29-
default: false
30-
},
31-
// maskClick
32-
maskClick: {
33-
type: Boolean,
34-
default: true
35-
}
36-
},
37-
data() {
38-
return {
39-
ani: '',
40-
show: false
41-
}
42-
},
43-
created() {},
44-
methods: {
45-
clear() {},
46-
open() {
47-
this.show = true
48-
this.$nextTick(() => {
49-
setTimeout(() => {
50-
this.ani = 'uni-' + this.type
51-
}, 30)
52-
})
53-
},
54-
close(type) {
55-
if (!this.maskClick && type) return
56-
this.ani = ''
57-
this.$nextTick(() => {
58-
setTimeout(() => {
59-
this.show = false
60-
}, 300)
61-
})
62-
}
63-
}
64-
}
65-
</script>
66-
<style>
67-
@charset "UTF-8";
68-
69-
.uni-popup {
70-
position: fixed;
71-
top: 50px;
72-
top: 0;
73-
bottom: 0;
74-
left: 0;
75-
right: 0;
76-
z-index: 999;
77-
overflow: hidden
78-
}
79-
80-
.uni-popup__mask {
81-
position: absolute;
82-
top: 0;
83-
bottom: 0;
84-
left: 0;
85-
right: 0;
86-
z-index: 998;
87-
background: rgba(0, 0, 0, .4);
88-
opacity: 0
89-
}
90-
91-
.uni-popup__mask.ani {
92-
transition: all .3s
93-
}
94-
95-
.uni-popup__mask.uni-bottom,
96-
.uni-popup__mask.uni-center,
97-
.uni-popup__mask.uni-top {
98-
opacity: 1
99-
}
100-
101-
.uni-popup__wrapper {
102-
position: absolute;
103-
z-index: 999;
104-
box-sizing: border-box
105-
}
106-
107-
.uni-popup__wrapper.ani {
108-
transition: all .3s
109-
}
110-
111-
.uni-popup__wrapper.top {
112-
top: 0;
113-
left: 0;
114-
width: 100%;
115-
transform: translateY(-100%)
116-
}
117-
118-
.uni-popup__wrapper.bottom {
119-
bottom: 0;
120-
left: 0;
121-
width: 100%;
122-
transform: translateY(100%)
123-
}
124-
125-
.uni-popup__wrapper.center {
126-
width: 100%;
127-
height: 100%;
128-
display: flex;
129-
justify-content: center;
130-
align-items: center;
131-
transform: scale(1.2);
132-
opacity: 0
133-
}
134-
135-
.uni-popup__wrapper-box {
136-
position: relative;
137-
box-sizing: border-box
138-
}
139-
140-
.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
141-
padding: 30upx;
142-
background: #fff
143-
}
144-
145-
.uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box {
146-
position: relative;
147-
max-width: 80%;
148-
max-height: 80%;
149-
overflow-y: scroll
150-
}
151-
152-
.uni-popup__wrapper.uni-custom.bottom .uni-popup__wrapper-box,
153-
.uni-popup__wrapper.uni-custom.top .uni-popup__wrapper-box {
154-
width: 100%;
155-
max-height: 500px;
156-
overflow-y: scroll
157-
}
158-
159-
.uni-popup__wrapper.uni-bottom,
160-
.uni-popup__wrapper.uni-top {
161-
transform: translateY(0)
162-
}
163-
164-
.uni-popup__wrapper.uni-center {
165-
transform: scale(1);
166-
opacity: 1
167-
}
1+
<template>
2+
<view v-if="showPopup" class="uni-popup">
3+
<view :class="[ani, animation ? 'ani' : '', !custom ? 'uni-custom' : '']" class="uni-popup__mask" @click="close(true)" />
4+
<view :class="[type, ani, animation ? 'ani' : '', !custom ? 'uni-custom' : '']" class="uni-popup__wrapper" @click="close(true)">
5+
<view class="uni-popup__wrapper-box" @click.stop="clear">
6+
<slot />
7+
</view>
8+
</view>
9+
</view>
10+
</template>
11+
12+
<script>
13+
export default {
14+
name: 'UniPopup',
15+
props: {
16+
// 开启动画
17+
animation: {
18+
type: Boolean,
19+
default: true
20+
},
21+
// 弹出层类型,可选值,top: 顶部弹出层;bottom:底部弹出层;center:全屏弹出层
22+
type: {
23+
type: String,
24+
default: 'center'
25+
},
26+
// 是否开启自定义
27+
custom: {
28+
type: Boolean,
29+
default: false
30+
},
31+
// maskClick
32+
maskClick: {
33+
type: Boolean,
34+
default: true
35+
},
36+
show: {
37+
type: Boolean,
38+
default: true
39+
}
40+
},
41+
data() {
42+
return {
43+
ani: '',
44+
showPopup: false
45+
}
46+
},
47+
watch: {
48+
show(newValue) {
49+
if (newValue) {
50+
this.open()
51+
} else {
52+
this.close()
53+
}
54+
}
55+
},
56+
created() {},
57+
methods: {
58+
clear() {},
59+
open() {
60+
this.$emit('change', {
61+
show: true
62+
})
63+
this.showPopup = true
64+
this.$nextTick(() => {
65+
setTimeout(() => {
66+
this.ani = 'uni-' + this.type
67+
}, 30)
68+
})
69+
},
70+
close(type) {
71+
if (!this.maskClick && type) return
72+
this.$emit('change', {
73+
show: false
74+
})
75+
this.ani = ''
76+
this.$nextTick(() => {
77+
setTimeout(() => {
78+
this.showPopup = false
79+
}, 300)
80+
})
81+
}
82+
}
83+
}
84+
</script>
85+
<style>
86+
@charset "UTF-8";
87+
88+
.uni-popup {
89+
position: fixed;
90+
top: 0;
91+
top: 0;
92+
bottom: 0;
93+
left: 0;
94+
right: 0;
95+
z-index: 99999;
96+
overflow: hidden
97+
}
98+
99+
.uni-popup__mask {
100+
position: absolute;
101+
top: 0;
102+
bottom: 0;
103+
left: 0;
104+
right: 0;
105+
z-index: 998;
106+
background: rgba(0, 0, 0, .4);
107+
opacity: 0
108+
}
109+
110+
.uni-popup__mask.ani {
111+
transition: all .3s
112+
}
113+
114+
.uni-popup__mask.uni-bottom,
115+
.uni-popup__mask.uni-center,
116+
.uni-popup__mask.uni-top {
117+
opacity: 1
118+
}
119+
120+
.uni-popup__wrapper {
121+
position: absolute;
122+
z-index: 999;
123+
box-sizing: border-box
124+
}
125+
126+
.uni-popup__wrapper.ani {
127+
transition: all .3s
128+
}
129+
130+
.uni-popup__wrapper.top {
131+
top: 0;
132+
left: 0;
133+
width: 100%;
134+
transform: translateY(-100%)
135+
}
136+
137+
.uni-popup__wrapper.bottom {
138+
bottom: 0;
139+
left: 0;
140+
width: 100%;
141+
transform: translateY(100%)
142+
}
143+
144+
.uni-popup__wrapper.center {
145+
width: 100%;
146+
height: 100%;
147+
display: flex;
148+
justify-content: center;
149+
align-items: center;
150+
transform: scale(1.2);
151+
opacity: 0
152+
}
153+
154+
.uni-popup__wrapper-box {
155+
position: relative;
156+
box-sizing: border-box
157+
}
158+
159+
.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
160+
padding: 30upx;
161+
background: #fff
162+
}
163+
164+
.uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box {
165+
position: relative;
166+
max-width: 80%;
167+
max-height: 80%;
168+
overflow-y: scroll
169+
}
170+
171+
.uni-popup__wrapper.uni-custom.bottom .uni-popup__wrapper-box,
172+
.uni-popup__wrapper.uni-custom.top .uni-popup__wrapper-box {
173+
width: 100%;
174+
max-height: 500px;
175+
overflow-y: scroll
176+
}
177+
178+
.uni-popup__wrapper.uni-bottom,
179+
.uni-popup__wrapper.uni-top {
180+
transform: translateY(0)
181+
}
182+
183+
.uni-popup__wrapper.uni-center {
184+
transform: scale(1);
185+
opacity: 1
186+
}
168187
</style>

‎pages.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,4 +1126,4 @@
11261126
}
11271127
]
11281128
}
1129-
}
1129+
}

0 commit comments

Comments
 (0)