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>
相关推荐
VillanelleS7 分钟前
React进阶之React状态管理&CRA
前端·javascript·react.js
前端_yu小白29 分钟前
vue2项目生产环境移除console.log
前端·javascript·vue.js
吉水于人35 分钟前
Arcgis/GeoScene API for JavaScript 三维场景底图网格设为透明
前端·javascript·arcgis
优雅永不过时·44 分钟前
Three.js编辑器百度搜索 Top 1
前端·javascript·学习·编辑器·three
无限大.1 小时前
前端知识速记--JS篇:instanceof
开发语言·前端·javascript
cs_dn_Jie2 小时前
uniapp + vite + 使用多个 ui 库
vue.js·ui·uni-app·vite
揣晓丹2 小时前
JAVA实战开源项目:宠物咖啡馆平台(Vue+SpringBoot) 附源码
java·vue.js·spring boot·spring·开源
無铭之辈3 小时前
学习Vue的必要基础
前端·vue.js·学习
111Hertz4 小时前
Vue 3 + Vite:现代前端开发的完美组合
vue.js
九幽归墟4 小时前
浅析Transfer-Encoding: chunked在流式与边缘渲染中的应用
前端·javascript