el-table template slot-scope=“scope“ 不显示内容

有时候,按以下方法写的el-table的操作列会不显示内容,可用 “template 里面的属性改为 #default="scope"。 重点:【template外围标签el-table-column 加上 key="slot"属性】” 的方法修改。 

<el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="date"
      label="日期"
      width="150">
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      width="120">
    </el-table-column>
    <el-table-column
      prop="province"
      label="省份"
      width="120">
    </el-table-column>
    <el-table-column
      prop="city"
      label="市区"
      width="120">
    </el-table-column>
    <el-table-column
      prop="address"
      label="地址"
      width="300">
    </el-table-column>
    <el-table-column
      prop="zip"
      label="邮编"
      width="120">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        <el-button type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>

解决办法代码:

<el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="date"
      label="日期"
      width="150">
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      width="120">
    </el-table-column>
    <el-table-column
      prop="province"
      label="省份"
      width="120">
    </el-table-column>
    <el-table-column
      prop="city"
      label="市区"
      width="120">
    </el-table-column>
    <el-table-column
      prop="address"
      label="地址"
      width="300">
    </el-table-column>
    <el-table-column
      prop="zip"
      label="邮编"
      width="120">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100"
      key="slot">
      <template #default="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        <el-button type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>

相关推荐

  1. el-table template slot-scope=“scope“ 显示内容

    2024-07-17 07:52:03       26 阅读
  2. Vue3中el-table表格数据显示

    2024-07-17 07:52:03       42 阅读
  3. dataGridView 绑定List 显示内容刷新

    2024-07-17 07:52:03       39 阅读

最近更新

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

    2024-07-17 07:52:03       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-17 07:52:03       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-17 07:52:03       58 阅读
  4. Python语言-面向对象

    2024-07-17 07:52:03       69 阅读

热门阅读

  1. PICO,迷途VR?

    2024-07-17 07:52:03       24 阅读
  2. ubuntu 18 cuda 11.8 安装 vllm

    2024-07-17 07:52:03       24 阅读
  3. LLM大语言模型研究方向总结剖析

    2024-07-17 07:52:03       21 阅读
  4. 如何在SpringCloud中优雅实现服务注册与发现

    2024-07-17 07:52:03       22 阅读
  5. 嵌入式linux相机 摄像头模块

    2024-07-17 07:52:03       31 阅读
  6. 服务器网络配置

    2024-07-17 07:52:03       26 阅读