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>
相关推荐
syt_10135 分钟前
grid布局之-子项放置4
开发语言·javascript·ecmascript
spencer_tseng1 小时前
jquery download
javascript·jquery
极速蜗牛1 小时前
告别部署焦虑!PinMe:前端开发者的极简部署神器
前端·javascript
by__csdn2 小时前
微前端架构:从理论到实践的全面解析
前端·javascript·vue.js·架构·typescript·vue·ecmascript
小福气_2 小时前
自定义组件 vue3+elementPlus
前端·javascript·vue.js
程序员博博2 小时前
这才是vibe coding正确的打开方式 - 手把手教你开发一个MCP服务
javascript·人工智能·后端
是谁眉眼3 小时前
vue环境变量
前端·javascript·vue.js
鹏北海-RemHusband3 小时前
Vue 组件解耦实践:用回调函数模式替代枚举类型传递
前端·javascript·vue.js
用户6600676685393 小时前
斐波那契数列:从递归到缓存优化的极致拆解
前端·javascript·算法
NuLL3 小时前
异步并行任务执行工具
javascript