在表格组件中,是不支持 \n
\r
来进行字符串的换行的,想要在单元格td下使字符串换行需要一个html格式及\br
来进行换行,这时我们就需要在每个td当中建立一个插槽模板,然后再以v-html的形式来插入html格式字符串
结构:
<a-table
:loading="loading"
:pagination="false"
:columns="columns"
:data-source="showList"
bordered
size="middle"
:scroll="{ x:'100%',y: 'calc(100vh - 370px)' }"
>
<template v-for="col in ['表头一',’表头二‘]" :slot="col" slot-scope="text, record,index">
<div :class="col" :key="col">
<div :key="index" v-html="text"></div>
</div>
</template>
</a-table>
这时候,展示内的字符串拼接就需要用html结构的字符串
this.showList[this.key]['doneWaterWellCount' + (month - 1)] += this.showList[this.key]['doneWaterWellCount' + (month - 1)] === '' ? '<span>' + item.wellTime + '</span>' : ' </br> ' + '<span>' + item.wellTime + '</span>'