常用于展示鼠标 hover 时的提示信息。

基础用法

在这里我们提供 9 种不同方向的展示方式,可以通过以下完整示例来理解,选择你要的效果。

使用content属性来决定hover时的提示信息。由placement属性决定展示效果:placement属性值为:方向-对齐位置;四个方向:topleftrightbottom;三种对齐位置:startend,默认为空。如placement="left-end",则提示信息出现在目标元素的左侧,且提示信息的底部与目标元素的底部对齐。

 <div class="box">
<div class="top">
<el-tooltip class="item" effect="dark" content="Top Left 提示文字" placement="top-start">
<el-button>上左</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Top Center 提示文字" placement="top">
<el-button>上边</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Top Right 提示文字" placement="top-end">
<el-button>上右</el-button>
</el-tooltip>
</div>
<div class="left">
<el-tooltip class="item" effect="dark" content="Left Top 提示文字" placement="left-start">
<el-button>左上</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Left Center 提示文字" placement="left">
<el-button>左边</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Left Bottom 提示文字" placement="left-end">
<el-button>左下</el-button>
</el-tooltip>
</div> <div class="right">
<el-tooltip class="item" effect="dark" content="Right Top 提示文字" placement="right-start">
<el-button>右上</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Right Center 提示文字" placement="right">
<el-button>右边</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Right Bottom 提示文字" placement="right-end">
<el-button>右下</el-button>
</el-tooltip>
</div>
<div class="bottom">
<el-tooltip class="item" effect="dark" content="Bottom Left 提示文字" placement="bottom-start">
<el-button>下左</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Bottom Center 提示文字" placement="bottom">
<el-button>下边</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="Bottom Right 提示文字" placement="bottom-end">
<el-button>下右</el-button>
</el-tooltip>
</div>
</div> <style>
.box {
width: 400px; .top {
text-align: center;
} .left {
float: left;
width: 60px;
} .right {
float: right;
width: 60px;
} .bottom {
clear: both;
text-align: center;
} .item {
margin: 4px;
} .left .el-tooltip__popper,
.right .el-tooltip__popper {
padding: 8px 10px;
}
}
</style>

主题

Tooltip 组件提供了两个不同的主题:darklight

通过设置effect属性来改变主题,默认为dark

 <el-tooltip content="Top center" placement="top">
<el-button>Dark</el-button>
</el-tooltip>
<el-tooltip content="Bottom center" placement="bottom" effect="light">
<el-button>Light</el-button>
</el-tooltip>

更多 Content

展示多行文本或者是设置文本内容的格式

用具名 slot 分发content,替代tooltip中的content属性。

 <el-tooltip placement="top">
<div slot="content">多行信息<br/>第二行信息</div>
<el-button>Top center</el-button>
</el-tooltip>

高级扩展

除了这些基本设置外,还有一些属性可以让使用者更好的定制自己的效果:

transition 属性可以定制显隐的动画效果,默认为fade-in-linear。 如果需要关闭 tooltip 功能,disabled 属性可以满足这个需求,它接受一个Boolean,设置为true即可。

事实上,这是基于 Vue-popper 的扩展,你可以自定义任意 Vue-popper 中允许定义的字段。 当然 Tooltip 组件实际上十分强大,文末的API文档会做一一说明。

 <template>
<el-tooltip :disabled="disabled" content="点击关闭 tooltip 功能" placement="bottom" effect="light">
<el-button @click="disabled = !disabled">点击{{disabled ? '开启' : '关闭'}} tooltip 功能</el-button>
</el-tooltip>
</template>

tooltip 内不支持 router-link 组件,请使用 vm.$router.push 代替。

tooltip 内不支持 disabled form 元素,参考MDN,请在 disabled form 元素外层添加一层包裹元素。

Attributes

参数 说明 类型 可选值 默认值
effect 默认提供的主题 String dark/light dark
content 显示的内容,也可以通过 slot#content 传入 DOM String
placement Tooltip 的出现位置 String top/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-end bottom
value(v-model) 状态是否可见 Boolean false
disabled Tooltip 是否可用 Boolean false
offset 出现位置的偏移量 Number 0
transition 定义渐变动画 String el-fade-in-linear
visible-arrow 是否显示 Tooltip 箭头,更多参数可见Vue-popper Boolean true
popper-options popper.js 的参数 Object 参考 popper.js 文档 { boundariesElement: 'body', gpuAcceleration: false }
open-delay 延迟出现,单位毫秒 Number 0
manual 手动控制模式,设置为 true 后,mouseenter 和 mouseleave 事件将不会生效 Boolean false
popper-class 为 Tooltip 的 popper 添加类名 String
enterable 鼠标是否可进入到 tooltip 中 Boolean true
hide-after Tooltip 出现后自动隐藏延时,单位毫秒,为 0 则不会自动隐藏 number 0

Tooltip 文字提示的更多相关文章

  1. 修改Tooltip 文字提示 的背景色 箭头颜色

    3==>vue 鼠标右击<div @contextmenu.prevent="mouseRightClick">prevent是阻止鼠标的默认事件 4==> ...

  2. iview 如何在表格中给操作图标添加Tooltip文字提示?

    项目需要用到的iview 表格中操作项目有各种各样的图标,而各种各样的图标代表不同的操作,面对新用户可能很懵,那如何给这些图标添加Tooltip文字提示? 废话不多讲,直接看代码: <templ ...

  3. 在element-ui的表格组件中为表头添加Tooltip 文字提示

    在使用表格组件的时候经常遇到的问题,列数很多,而表头的文字描述长度很长 <el-table-column v-if="!column.event" v-for="( ...

  4. js实现tooltip动态提示效果(文字版)

    页面中经常用到鼠标移动到一个元素上面显示提示的功能,最开始的做法是在下面创建一个div然后动态显示这个div,但是这样需要加很多div,比较麻烦. 针对上面个的需求,这边写了一个tooltip动态提示 ...

  5. jQuery实现的简单文字提示效果模拟title(转)

    来源 http://www.cnblogs.com/puzi0315/archive/2012/10/17/2727693.html 模拟title实现效果,可以修改文字的样式,换行等. 文件下载: ...

  6. jQuery图片提示和文字提示

    图片提示: 效果如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...

  7. DOM操作在jQuery中的实用------文字提示和图片提示

    关于文字提示想必是家喻户晓,操作呢说简单一点就是在超链接中加入title属性.但是在人机交互越来越倍受恩宠的年代,依靠浏览器自带的文字提示即title属性,提示效果的响应速度就(还是人艰不拆了吧~)s ...

  8. Tooltip浮动提示框效果(掌握里面的小知识)

    使用原生JavaScript设计和实现Tooltip浮动提示框特效,了解代码简化.事件绑定.事件冒泡等技巧和知识. 特效四个关键点:显示:鼠标移到ToolTip超链接上时,ToolTip提示框可以显示 ...

  9. Unity 双击Esc或者返回退出游戏,有文字提示

    第一次点击Esc或者返回,显示提示文字"再次按下返回键退出游戏",在文字消失之前再次点击Esc或者返回,退出游戏. 此脚本挂在Text文字提示上: using UnityEngin ...

随机推荐

  1. Oracle【增删改&数据的备份】

    增删改的SQL语句执行完毕后,不会立马进行数据的写入数据库(这时数据在内存中),需要手动对数据进行提交(commit),如果数据出问题,可以使用回滚.主键:非空唯一的 --在一张表中,某字段值是非空唯 ...

  2. 接口测试工具中 post请求如何传递多维数组

    1,请求参数为数组时,可以采用传递 json格式的形式传递请求参数(字段及字段对应的值如查是字符,都应该用双引号括起来.用单引号会无法识别),后台接收的数据为json . 2,直接以数组格式来请请求 ...

  3. python文件操作:文件处理与操作模式

    一,文件处理的模式基本概念 #coding:utf-8 # 一: 文件处理的三个步骤 # 1. 打开文件拿到文件对象(文件对象====>操作系统打开文件====>硬盘) # f=open( ...

  4. 日常系统维护之修复linux的grub引导

    恩,不知道怎么表达为win10的更新很烦人,其实我感觉windows用的不是那么顺手,但是制作视频的时候还是要用到,图片的话linux也可以胜任,毕竟GUN IMAGE还是挺不错的,但到了视频制作方面 ...

  5. QTP(1)

    一.概念 1.什么是软件测试? 使用人工或者自动手段来运行或者测试某个软件的过程,其目的在于检验程序是否满足需求规格说明书或者弄清实际结果与预期结果之间的差异. (1)软件(程序+文档+数据)测试 ( ...

  6. CentOS5、CentOS6启动流程

    这三篇文章讲的都很好,可以看一下 http://os.51cto.com/art/201407/446819.htm http://www.mamicode.com/info-detail-11656 ...

  7. k8s部署ingress-nginx

    ingress-nginx的部署方式有多种,本文介绍nodeport方式和hostnetwork方式: 一.nodeport方式 1.下载mandatory.yaml文件:https://raw.gi ...

  8. nginx第七天

    nginx的proxy_buffering和proxy_cache 两个都是nginx代理中内存设置相关的参数. proxy_buffering设置 proxy_buffering主要是实现被代理服务 ...

  9. MD5 加密 字符串

    //获取字符串的MD5码 public string CreateMD5Hash(string input) { // Use input string to calculate MD5 hash S ...

  10. JVM(九),垃圾回收回收算法

    九.垃圾回收回收算法 1.标记-清除(Mark and Sweep) 缺点是内存空间碎片化太严重 2.复制算法(Copying) (1)复制算法介绍 (2)复制算法优势 3.标记-整理算法(Compa ...