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>
相关推荐
kyriewen114 小时前
你点的“刷新”是假刷新?前端路由的瞒天过海术
开发语言·前端·javascript·ecmascript·html5
摇滚侠5 小时前
JAVA 项目教程《苍穹外卖-12》,微信小程序项目,前后端分离,从开发到部署
java·开发语言·vue.js·node.js
Timer@5 小时前
LangChain 教程 04|Agent 详解:让 AI 学会“自己干活“
javascript·人工智能·langchain
阿珊和她的猫6 小时前
TypeScript中的never类型: 深入理解never类型的使用场景和特点
javascript·typescript·状态模式
九皇叔叔9 小时前
003-SpringSecurity-Demo 统一响应类
java·javascript·spring·springsecurity
低代码布道师11 小时前
纯代码实战:MBA培训管理系统 (十四) ——用户管理(批量选择与批量删除)
javascript·nextjs
打瞌睡的朱尤11 小时前
建立vue项目
vue.js
Hello--_--World12 小时前
JavaScript运行机制、v8原理、js事件循环
开发语言·javascript·ecmascript
bearpping13 小时前
Spring Boot + Vue 全栈开发实战指南
vue.js·spring boot·后端
敲敲了个代码15 小时前
React 那么多状态管理库,到底选哪个?如果非要焊死一个呢?这篇文章解决你的选择困难症
前端·javascript·学习·react.js·前端框架