• 【ElementUI】ElementUI Tooltip 根据内容判断是否显示、文字提示自定义样式


    【ElementUI】ElementUI Tooltip 根据内容判断是否显示、文字提示自定义样式

    封装组件自定义内容

    <template>
      <span v-if="['', null, undefined].indexOf(content) === -1">
        <el-tooltip :content="content" effect="light" placement="bottom" popper-class="tooltip-box">
          <slot></slot>
        </el-tooltip>
      </span>
      <span v-else>
        <slot></slot>
      </span>
    </template>
    
    <script>
    export default {
      name: "tooltipBox",
      props: {
        content: {
          type: String,
          default: "",
        },
      },
    };
    </script>
    
    <style>
    .tooltip-box.el-tooltip__popper .popper__arrow {
      /* 上方箭头 */
      border-top-color: #e8f4ff !important;
      /* 下方箭头 */
      border-bottom-color: #e8f4ff !important;
    }
    
    .tooltip-box.el-tooltip__popper .popper__arrow:after {
      border-top-color: #e8f4ff !important;
      border-bottom-color: #e8f4ff !important;
    }
    
    /* tooltip主体部分 */
    .tooltip-box.el-tooltip__popper {
      color: #1890ff;
      background-color: #e8f4ff !important;
      border-color: #d1e9ff !important;
      box-shadow: 0px 0px 7px 0px rgba(42, 42, 42, 0.2) !important;
    }
    </style>
    
    • 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
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44

    使用封装的组件

    import tooltipBox from "./components/tooltipBox";
    
    export default {
      components: {
        tooltipBox
      },
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    <el-table-column label="讲课内容" align="center" prop="lectureContent">
      <template slot-scope="scope">
        <tooltipBox :content="scope.row.lectureContent">
          <el-input v-model="scope.row.lectureContent"></el-input>
        </tooltipBox>
      </template>
    </el-table-column>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

  • 相关阅读:
    JavaEE之HTTP协议 Ⅱ
    Variable (mathematics)
    【InternLM 笔记】使用InternLM2-chat-1.8b制作时事问答知识库
    蓝桥杯刷题--python-12
    制作自定义版本 kernel 镜像
    Java反射系列(2):从Class获取父类方法说起
    购物车——js小项目实例
    Pytorch 多卡并行(3)—— 使用 DDP 加速 minGPT 训练
    后台管理系统SQL注入漏洞
    Hbase底层原理简介(一)
  • 原文地址:https://blog.csdn.net/qq_38762237/article/details/133045106