Skip to content

Commit a9b108d

Browse files
fix: 🐛 修复Popover指定placement后箭头显示异常的问题(#306)
* fix: 🐛 修复Popover组件placement异常的问题 * fix: 🐛 修复Popover指定placement后未显示箭头的问题 --------- closed(#295)
1 parent 3d6ddbd commit a9b108d

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

src/pages/popover/Index.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,33 @@
33
<wd-toast />
44

55
<view @click="closeOutside" class="wrapper">
6+
<demo-block title="位置">
7+
<wd-radio-group v-model="placement" inline shape="dot">
8+
<wd-radio value="bottom" custom-class="custom-radio">bottom</wd-radio>
9+
<wd-radio value="bottom-start" custom-class="custom-radio">bottom-start</wd-radio>
10+
<wd-radio value="bottom-end" custom-class="custom-radio">bottom-end</wd-radio>
11+
<wd-radio value="top" custom-class="custom-radio">top</wd-radio>
12+
<wd-radio value="top-start" custom-class="custom-radio">top-start</wd-radio>
13+
<wd-radio value="top-end" custom-class="custom-radio">top-end</wd-radio>
14+
<wd-radio value="left" custom-class="custom-radio">left</wd-radio>
15+
<wd-radio value="left-start" custom-class="custom-radio">left-start</wd-radio>
16+
<wd-radio value="left-end" custom-class="custom-radio">left-end</wd-radio>
17+
<wd-radio value="right" custom-class="custom-radio">right</wd-radio>
18+
<wd-radio value="right-start" custom-class="custom-radio">right-start</wd-radio>
19+
<wd-radio value="right-end" custom-class="custom-radio">right-end</wd-radio>
20+
</wd-radio-group>
21+
</demo-block>
622
<demo-block custom-class="pop" title="基本用法">
723
<view class="center">
8-
<wd-popover id="pop1" content="这是一段内容。" v-model="show1" @change="handleChange1">
24+
<wd-popover id="pop1" content="这是一段内容。" :placement="placement" v-model="show1" @change="handleChange1">
925
<wd-button data-id="pop1">点击展示</wd-button>
1026
</wd-popover>
1127
</view>
1228
</demo-block>
1329

1430
<demo-block custom-class="pop" title="嵌套信息">
1531
<view class="center list">
16-
<wd-popover v-model="show2" use-content-slot @change="handleChange2">
32+
<wd-popover v-model="show2" use-content-slot :placement="placement" @change="handleChange2">
1733
<template #content>
1834
<view class="pop-content">这是一段自定义样式的内容。</view>
1935
</template>
@@ -24,7 +40,7 @@
2440

2541
<demo-block custom-class="pop" title="列表展示">
2642
<view class="center list">
27-
<wd-popover v-model="show3" mode="menu" :content="menu" @menuclick="link" @change="handleChange3">
43+
<wd-popover v-model="show3" mode="menu" :placement="placement" :content="menu" @menuclick="link" @change="handleChange3">
2844
<wd-button>列表</wd-button>
2945
</wd-popover>
3046
</view>
@@ -36,11 +52,13 @@
3652
import { useToast } from '@/uni_modules/wot-design-uni'
3753
import { ref } from 'vue'
3854
import { useQueue } from '@/uni_modules/wot-design-uni'
55+
import type { PlacementType } from '@/uni_modules/wot-design-uni/components/wd-popover/types'
3956
4057
const { closeOutside } = useQueue()
4158
const toast = useToast()
4259
43-
const show = ref<boolean>(false)
60+
const placement = ref<PlacementType>('bottom')
61+
4462
const show1 = ref<boolean>(false)
4563
const show2 = ref<boolean>(false)
4664
const show3 = ref<boolean>(false)
@@ -95,6 +113,10 @@ function handleChange3() {
95113
overflow: visible !important;
96114
padding: 10px;
97115
}
116+
:deep(.custom-radio) {
117+
height: 32px !important;
118+
line-height: 32px !important;
119+
}
98120
.wrapper {
99121
width: 100%;
100122
height: 100vh;

src/uni_modules/wot-design-uni/components/common/abstracts/_mixin.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,46 +286,54 @@
286286
height: $size;
287287
background-color: $bg;
288288
position: absolute;
289+
left: 0;
289290
bottom: calc(-1 * $size / 2);
290291
transform: rotateZ(45deg);
291292
box-shadow: $box-shadow;
292293
}
293294
}
294295
@include e(arrow-up) {
295296
transform: translateX(-50%);
297+
top: 0;
296298
&:after {
297299
content: "";
298300
width: $size;
299301
height: $size;
300302
background-color: $bg;
301303
position: absolute;
304+
left: 0;
302305
top: calc(-1 * $size / 2);
303306
transform: rotateZ(45deg);
304307
box-shadow: $box-shadow;
305308
}
306309
}
307310
@include e(arrow-left) {
308311
transform: translateY(-50%);
312+
left: 0;
309313
&:after {
310314
content: "";
311315
width: $size;
312316
height: $size;
313317
background-color: $bg;
314318
position: absolute;
315319
left: calc(-1 * $size / 2);
320+
top: 0;
316321
transform: rotateZ(45deg);
317322
box-shadow: $box-shadow;
318323
}
319324
}
320325
@include e(arrow-right) {
321326
transform: translateY(-50%);
327+
right: 0;
328+
322329
&:after {
323330
content: "";
324331
width: $size;
325332
height: $size;
326333
background-color: $bg;
327334
position: absolute;
328335
right: calc(-1 * $size / 2);
336+
top: 0;
329337
transform: rotateZ(45deg);
330338
box-shadow: $box-shadow;
331339
}

src/uni_modules/wot-design-uni/components/wd-popover/wd-popover.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ watch(
8888
}
8989
)
9090
91+
watch(
92+
() => props.placement,
93+
() => {
94+
popover.init(props.placement, props.visibleArrow, selector)
95+
}
96+
)
97+
9198
watch(
9299
() => props.modelValue,
93100
(newValue) => {

0 commit comments

Comments
 (0)