若依 富文本内容,修改行

找到这列

<el-table-column label="文章内容(富文本)" align="center" prop="content" />

改成下面这样就行:

<el-table-column label="文章内容(富文本)" align="center" width="320">
  <template #default="scope">
    <div class="content-cell">
      {{ stripHtml(scope.row.content) }}
    </div>
  </template>
</el-table-column>

然后在 script setup 里加一个方法:

function stripHtml(html) {
  if (!html) return ''
  return html.replace(/<[^>]+>/g, '').replace(/&nbsp;/gi, ' ').trim()
}

最后在底部加样式:

<style scoped lang="scss">
.content-cell {
  line-height: 22px;
  max-height: 44px;
  overflow: hidden;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

  word-break: break-word;
  text-align: left;
}
</style>
最后修改:2026 年 03 月 09 日
咱们谁跟谁,用不着~