王多静

这里是我的记事本

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

vue-element的<el-tooltip>气泡提示失效问题

问题:

页面按钮太多, 弹框很多, 但是有些不必要的, UI也没说有限制,  我想用<el-tooltip>来根据不同状态来用气泡提示 ,

使用时<el-tooltip>经常用来包含<el-button>, 但是遇到<el-button>为禁用disabled=true的时候, 会失效.

 

解决办法:

使用<span>来让这些<el-button>块成为内联元素( ele的UI弹性布局 ,<el-col :span="24"> 布局很难操作 )

最终结果:

 

 

代码:

复制代码
<el-tooltip content="【查看】请先选中一条数据进行操作!"
                  :disabled="activeList && activeList.length == 1 ? true : false"
                  placement="top">
        <span>
          <el-button :disabled="activeList && activeList.length==1 ? false : true"
                     @click="handleButtonType('see')">查看</el-button>
        </span>

      </el-tooltip>
      <el-tooltip :disabled="activeList && activeList.length==1 && activeList[0].status == 'noaudit' ? true : false"
                  placement="top">
        <div slot="content">【修改】、【删除】、【保存1】按钮<br />仅可对状态为保存1的数据进行操作!</div>
        <span class="mLeft10 mRight10">
          <el-button :disabled="activeList && activeList.length==1 && activeList[0].status == 'noaudit' ? false : true"
                     @click="handleButtonType('edit')">修改</el-button>
          <el-button :disabled="activeList && activeList.length==1 && activeList[0].status == 'noaudit' ? false : true"
                     @click="handleButtonType('del')">删除</el-button>
          <el-button :disabled="activeList && activeList.length==1 && activeList[0].status == 'noaudit' ? false : true"
                     @click="handleButtonType('audit')">嗯嗯嗯</el-button>
        </span>
</el-tooltip>
<el-tooltip content="【保存】仅可对状态为保存2的数据进行操作!"
                  :disabled="activeList && activeList.length==1 && activeList[0].status == 'audit' ? true : false"
                  placement="top">
        <span>
          <el-button type="primary"
                     :disabled="activeList && activeList.length==1 && activeList[0].status == 'audit' ? false : true"
                     @click="handleButtonType('noaudit')">保存2</el-button>
        </span>
</el-tooltip>
复制代码

 

posted on   王多静  阅读(11202)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
点击右上角即可分享
微信分享提示