element表格数据,表头上(下)角标,html字符串渲染

1. 问题描述

在动态渲染的element表格中,表头和表中数据是一个含有html的字符串,需要渲染

2. 效果


3. 代码
复制代码
const columns = ref([
  { text: '差值<sub>-3</sub> / 10<sup>-6</sup>℃<sup>-1</sup>', value: 'aallowErrorLower', align: 'center', required: true, width: '160' },
  { text: '世界<sub>和平</sub> / 国家<sup>富强</sup>', value: 'aallowErrorLower', align: 'center', required: true, width: '160' },
])

<el-table
      ref="tableRef"
      v-loading="tableLoading"
      :data="list"
    >
      <el-table-column
        v-for="item in columns"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
      >
        <template #header>
            <span v-html="item.text" />
        </template>
        <template #default="scope">
        	//在这里,表格数据的值为 △α/10<sup>-6</sup>℃<sup>-1</sup>
        	// 使用将字符串转化为html即可实现
           <div v-html="scope.row[item.value]" /> 
        </template>
      </el-table-column>
    </el-table>
相关推荐
2分钟速写快排3 小时前
孔乙己的茴字有多少种写法?|AI 对话实时通信的三种实现
前端·javascript·github
Penge6665 小时前
JavaScript:BOM 详解
前端
Penge6665 小时前
Vite vs Webpack:前端构建工具原理与实战
前端
Penge6665 小时前
前端包管理工具:npm、Yarn、pnpm 快速入门
前端
Penge6666 小时前
Sass 了解
前端
Penge6666 小时前
Webpack 打包从 0 到 1 实战笔记
前端
Penge6666 小时前
Webpack 入门:是什么、为什么需要、怎么使用?
前端
Penge6666 小时前
Ant Design(Antd)了解
前端
wangruofeng7 小时前
同一行代码,百种渲染:Asuka、React Native 与 Flutter 跨平台渲染机制深度拆解
前端·github
Penge6667 小时前
JavaScript 核心语法速通
前端