element ui-表头自定义提示框

文章描述了如何在Element-UI的表格中,当鼠标悬浮到特定列头时,使用el-tooltip显示提示框,包括使用v-if/v-else条件和自定义popper-class样式。
摘要由CSDN通过智能技术生成
  • 版本
    “element-ui”: “^2.15.5”,
  • 需求:鼠标悬浮到该列表头,显示提示框
  • 代码
	<el-table
        :data="xxxx"
       >
      <el-table-column  label="序号" width="40" type="index"  />
      <el-table-column
        v-for="(item) in xx2"
        :key="item.prop"
        :prop="item.prop"
        :label="item.lable"
        >
       // 表身插槽
        <template slot-scope="scope">
          <div
            v-if="scope.column.label !== 'xxx'">
            {{scope.row[scope.column.property] ? scope.row[scope.column.property] : '无'}}
          </div>
          <div v-else>
            <el-switch
              v-if="scope.column.label === '是否入伍'"
              v-model="scope.row[scope.column.property]"
              @change="changeSwitch(scope.column,scope.row,scope.$index)"
              active-text="是"
              inactive-text="否"
              active-value=1
              inactive-value=0
              >
            </el-switch>
          </div>
        </template>
		//  表头插槽+弹出提示框
        <template slot="header" slot-scope="scope">
          <span v-if="item.prop!='xxA'">{{ scope.column.label }}</span>
          // prop等于xxA 的有提示框
          <el-tooltip v-else  effect="dark" content="你想提示的弹框信息字段" placement="top">
              <span>{{ scope.column.label }}</span>
          </el-tooltip>
      </template>

		// 表身某一鼠标移入弹出提示框 重要的属性popper-class加类名 这个类的定义要另写一个单独的style里
		 <template slot-scope="scope">
			 <el-tooltip  effect="light" placement="right-start" popper-class="wh-slot">
	              <span>{{ scope.row.Name }}</span>
	              <div slot="content">
	                <p class="wh-slot-title">信息</p>
	                <p class="wh-slot-li"><span>所在班级:</span><span>{{ scope.row.xx}}</span></p>
	                <p class="wh-slot-li"><span>班主任:</span><span>{{ scope.row.nameB }}</span></p>
	              </div>
	          </el-tooltip>
  		</template>

      </el-table-column>
      </el-table>

// css
<style>
.wh-slot .wh-slot-title{
  text-align:center;
}
.wh-slot-li>span:nth-child(1){
  display: inline-block;
  width: 80px;
  text-align: right;
}
.wh-slot-li>span:nth-child(2){
  display: inline-block;
  width: 80px;
  /* text-align: right; */
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值