Files
tk-mini-program/uni_modules/yinrh-menu-popup/readme.md
pengxiaolong 8580cd18fa 优化
2025-07-25 16:39:52 +08:00

49 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## yinrh-menu-popup
仿IOS长按的悬浮菜单
## 使用方法
### 在``template``中直接使用
```
<yinrh-menu-popup v-model="value" :pop-data="menu" dynamic :x="x" :y="y" direction="row" theme="dark"
:placement="place" @tapPopup="tapPopup" />
```
### 在``template``中,需要出现菜单的 view 上添加 id 和 click 事件
```
<text id="popup-menu" @longTap="longTap">长按出现悬浮菜单</text>
```
### 在``script``中,添加 longTap 和 tapPopup 方法
```
longTap() {
let dom = uni.createSelectorQuery().in(this);
// popup-menu 为上面添加的 id 值
dom.select('#popup-menu').boundingClientRect();
dom.exec(data => {
// 配置 place、value、x、y 的值
let isTop = data[0].top >= 60,
place = isTop ? 'bottom' : 'top';
this.place = place + '-center';
this.value = !this.value;
this.x = data[0]['width'] / 2;
this.y = data[0][isTop ? 'top' : 'bottom'];
});
}
```
```
tapPopup(e) {
console.log(e);
}
```
## 参数说明
+ maskBg遮罩背景颜色默认 rgba(0,0,0,0),不透明
+ value显示或隐藏菜单true-显示false-隐藏,默认 true
+ x长按组件的中心值单位px
+ y长按组件的 top 或 bootom 值单位px
+ theme悬浮菜单的样式支持 light 和 dark默认 light
+ gap
+ triangle悬浮菜单的箭头true-显示false-隐藏,默认 true
+ dynamic悬浮菜单的显示方式true-动态false-静态,默认 true
+ popData悬浮菜单的列表
+ direction悬浮菜单排列方向支持 column 和 row默认 column
+ placement悬浮菜单的箭头相对于菜单的位置 top-start、top-end、bottom-start、bottom-end、top-center、bottom-center默认 top-start