情况说明:el-table中表格列返回的数据是富文本内容,带有html标签和css样式,但是表格展示不需要这些,需要摘除。
解决方法:
<el-table-column prop="message" min-width="150" label="内容" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ highlight(scope.row.message) }}</span>
</template>
</el-table-column>
截取富文本中的body部分,去除html标签
highlight(item) {
let relStyle = /<body[^>]*>([\s\S]*)<\/body>/
if (item.search(relStyle) > 0) {
let newHtml = relStyle.exec(item).toString()
return newHtml.replace(/<[^>]+>/g, '')
} else {
return item
}
}