Vue表格中鼠标移入移出input显示隐藏 ,有输入值不再隐藏

Vue表格中鼠标移入移出input显示隐藏 , 不再隐藏的效果

	<el-table
          ref="table"
          :data="tableDatas"
          border
          style="width: 100%"
          :span-method="arraySpanMethod"
          id="table"
          row-key="id"
          @cell-mouse-enter="editCell"
        >
		<el-table-column
            prop="name"
            label="排序"
            min-width="80"
            header-align="center"
            align="center"
            type="name"
          >
            <template slot-scope="scope">
              <el-input
                :ref="`name-${scope.row.id}`"
                v-model="scope.row.name"
                v-show="scope.row.id === tabClickId && tabClickLabel === '排序'"
                placeholder="排序"
                @blur="inputBlur(scope.row)"
              >
              </el-input>
              <div
                class="cell-text"
                v-show="scope.row.id !== tabClickId || tabClickLabel !== '排序'"
              >
                {
   {
    scope.row.name }}
              </div>
            </template>
         </el-table-column>
         <el-table-column
            prop="title"
            label="任务标题"
            min-width="80"
            header-align="center"
            align="center"
          >
            <template slot-scope="scope">
              <el-input
                :ref="`title-${scope.row.id}`"
                v-model="scope.row.title"
                v-show="
                  scope.row.id === tabClickId && tabClickLabel === '任务标题'
                "
                placeholder="任务标题"
                @blur="inputBlur(scope.row)"
              >
              </el-input>
              <div
                class="cell-text"
                v-show="
                  scope.row.id !== tabClickId || tabClickLabel !== '任务标题'
                "
              >
                {
   {
    scope.row.title }}
              </div>
            </template>
          </el-table-column>
	</el-table>

<script>
export default {
   
  data() {
   
    return {
   
      tabClickId: "",
      tabClickLabel: "",
      tableDatas: [
        {
   
          id: 1,
          name: "",
          title: "",
        },
     }
   },
   methods: {
   
    editCell(item, column, cell, event) {
   
      //根据点击的单元格判断是否可变成输入框
      switch (column.label) {
   
      //case内写你的不用鼠标移入显示的名称
        case "":
          return;
        default:
          this.tabClickId = item.id;
          this.tabClickLabel = column.label;
          break;
      }
    },
    // 失去焦点初始化
    inputBlur(item) {
   
      this.tabClickId = "";
      this.tabClickLabel = "";
      //这里还可以进行其他数据提交等操作
    },
  }

效果如下

默认

在这里插入图片描述

鼠标移入

在这里插入图片描述

鼠标移出有输入值

在这里插入图片描述

相关推荐

  1. layui实现鼠标/显示/隐藏tips

    2023-12-22 12:34:03       26 阅读
  2. 鼠标事件

    2023-12-22 12:34:03       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-22 12:34:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-22 12:34:03       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-22 12:34:03       82 阅读
  4. Python语言-面向对象

    2023-12-22 12:34:03       91 阅读

热门阅读

  1. 华纳云:怎么用python实现进程,线程和协程

    2023-12-22 12:34:03       62 阅读
  2. AI write rust 2

    2023-12-22 12:34:03       59 阅读
  3. rust热门前后端框架

    2023-12-22 12:34:03       61 阅读
  4. 密钥盐技术简介及作用(含示例)

    2023-12-22 12:34:03       64 阅读
  5. 力扣61. 旋转链表

    2023-12-22 12:34:03       63 阅读