el-table 对动态列表 中的某一列 指定宽度 内容解密 去除标签

javascript 复制代码
<el-table :fit="true" :data="tableData" style="width:calc(100vw)" @selection-change="handleSelectionChange" v-loading="loading" table-layout="auto">
      <el-table-column type="selection" width="20" />
      <el-table-column sortable label="Id" width="100"  prop="workitemId" align="center">            </el-table-column>

<el-table-column
        sortable
        v-for="item in showTableColumn"
        :key="item.prop"
        :fixed="item.fixed"
        align="left"
        :prop="item.prop"
        :min-width="item.minWidth"
        :width="computedWidth(item)"
        :show-overflow-tooltip="item.tooltip"
        :resizable="item.resizable"
        :label="item.label"
      >
      <template #default="{row}">
        <!-- link -->
        <template v-if="item.prop === 'title'">
           <el-link  type="primary" :underline="false" @click="showDetail(row)"> {{row.title }} </el-link>
        </template>
        <template v-if="item.prop === 'description'">
          <span v-if="row.description">{{(formattedUsers(row.description))}}</span>
         <!-- <span v-if="row.description" v-html="formattedUsers(row.description)"></span>
         <span v-else>暂无描述</span> -->
        </template>
      </template>
      </el-table-column>
      <!-- <el-table-column prop="action" label="操作" width="100">
      <template #default="scope">
          <el-button
            size="small"
            type="primary"
            link
            icon="Edit"
            @click="edit(scope.row)"
            >编辑</el-button
          >
     </template>
     </el-table-column> -->
    </el-table>


<script setup>

// 处理宽度
const computedWidth = computed(()=>{ 
  return function computedWidth(item) {
    // console.log(item);
    if (item.type === 'title') {
      return 370
    } else if (item.label === '描述') {
      return 276
    } else { 
      return 100
    }
  }
})

//解密AES并且去除相关img table等标签,保留纯文本
const formattedUsers = (val) => {
  return asc.decrypt(val).replace(/<[^>]+>/g, '');
}

</script>
相关推荐
工业甲酰苯胺6 小时前
TypeScript枚举类型应用:前后端状态码映射的最简方案
javascript·typescript·状态模式
谢尔登10 小时前
【React Native】ScrollView 和 FlatList 组件
javascript·react native·react.js
然我10 小时前
面试官:如何判断元素是否出现过?我:三种哈希方法任你选
前端·javascript·算法
kk_stoper11 小时前
如何通过API查询实时能源期货价格
java·开发语言·javascript·数据结构·python·能源
晨枫阳11 小时前
前端VUE项目-day1
前端·javascript·vue.js
颜酱11 小时前
抽离ant-design后台的公共查询设置
前端·javascript·ant design
绅士玖11 小时前
JavaScript 设计模式之单例模式🚀
前端·javascript·设计模式
Dream耀11 小时前
useReducer:React界的"灭霸手套",一个dispatch搞定所有状态乱局
前端·javascript·react.js
余大侠在劈柴12 小时前
pdf.js 开发指南:在 Web 项目中集成 PDF 预览功能
前端·javascript·学习·pdf
拾光拾趣录12 小时前
JavaScript屏幕切换检测方案
前端·javascript