Skip to content

Tooltip 长按提示组件

Tooltip组件主要用于长按操作,类似微信的长按气泡

温馨提示

本项目参考了 uView-Plus 开源项目的组件开发方式,基于 Vue 3 和 TypeScript 实现了自定义组件。目前该组件仍处于测试阶段。
感谢 uView-Plus 开源项目及其团队成员的贡献,他们的组件开发思路为本项目提供了宝贵地参考。如果需要了解更多组件开发细节,可以参考uView-Plus的 tooltip组件 的代码实现。

平台差异说明

APP(vue)H5微信小程序

基本使用示例

html
<!-- 全局使用 -->
<hy-tooltip text="复制内容"></hy-tooltip>
<!-- 单个组件引入 -->
<HyTooltip text="复制内容"></HyTooltip>
ts
import { HyTooltip } from "hy-app"

下方显示

html
<template>
    <hy-tooltip text="复制内容" direction="bottom"></hy-tooltip>
</template>

高亮选中文本背景色

html
<template>
    <hy-tooltip text="复制" bgColor="#e3e4e6"></hy-tooltip>
</template>

扩展按钮

html
<template>
    <hy-tooltip text="复制" :buttons="['扩展']"></hy-tooltip>
</template>

API

参数说明类型默认值
text需要显示的提示文字string-
copyText点击复制按钮时,复制的文本,为空则使用text值string-
size文本大小string | number14
color字体颜色string#606266
bgColor弹出提示框时,文本的背景色stringtransparent
direction弹出提示的方向,top-上方,bottom-下方top | bottomtop
zIndex弹出提示的z-indexnumber10071
showCopy是否显示复制按钮booleantrue
buttons扩展的按钮组array-
overlay是否显示透明遮罩以防止触摸穿透booleantrue
showToast是否显示复制成功或者失败的toastbooleantrue

Events

事件名说明回调参数
click点击触发事件index:被点击按钮的索引
00:46