本次需求:備注列內(nèi)容不換行【上圖為最終完成版】
第一次嘗試:
<template slot="remarks" slot-scope="text, record">
?????<span? :title="record.remarks" v-if="record.remarks.length >15" >{{ record.remarks.substring(0,15)+'...' }}</span>
????<span v-else-if="record.remarks.length <= 15"? >{{ record.remarks }}</span>
</template>
思路1沒什么問題吸奴,樣式會有問題,可能有其他方式優(yōu)化:用length判斷字符的長度缠局,中英文混輸情況下则奥,實際展示內(nèi)容可見寬度差別太大【如下圖】
==================================================================
第二次嘗試:
<template slot="remarks" slot-scope="text, record">
? ? ? ? ? ? ? ? <span style="display: inline-block;text-overflow: ellipsis;overflow: hidden !important;white-space: nowrap;width:250px;">{{ record.remarks }}</span>
</template>
-------------------------------------------------------------------------------------
設(shè)置?text-overflow: ellipsis;overflow: hidden;?white-space: nowrap;【必須】,用<nobr>標(biāo)簽頁不行
此外還要 設(shè)置寬度width狭园,寬度還不能是百分比读处,若設(shè)置百分比,什么值都無效唱矛,并且會導(dǎo)致顯示內(nèi)容擠掉其他列的情況【如下圖】罚舱,需要設(shè)置為固定的px才能生效
==========================================================================
以上均在 table 的?columns 已設(shè)置width 情況下進行: