Primereact TreeTable列提示换行问题:如何使用pre标签?
解决PrimeReact TreeTable表头Tooltip换行问题
直接用HTML换行标签<br/>或者<pre>标签结合Tooltip的escape配置就能搞定,步骤如下:
开启Tooltip的HTML解析
在headerTooltipOptions里添加escape: false——默认PrimeReact会转义所有HTML内容,开启这个配置后才能识别HTML标签。方法一:用
<br/>实现换行
把原有的 替换成<br/>,修改后的代码:
<Column columnKey="status" header="Status" body={status} style={{ width: '150px', textAlign: "center" }} headerTooltipOptions={{ event: "both", hideDelay: 1000, escape: false // 允许解析HTML }} headerTooltip="Status for non-leaf nodes: count of healthy, unhealthy, warning and missing leaf nodes.<br/>Status for leaf nodes: health status." />
- 方法二:用
<pre>标签保留格式
如果需要保留文本原有的换行、空格格式,直接把内容包裹在<pre>标签里,代码示例:
<Column columnKey="status" header="Status" body={status} style={{ width: '150px', textAlign: "center" }} headerTooltipOptions={{ event: "both", hideDelay: 1000, escape: false }} headerTooltip="<pre>Status for non-leaf nodes: count of healthy, unhealthy, warning and missing leaf nodes. Status for leaf nodes: health status.</pre>" />
补充说明:之前的
和 无效,是因为默认Tooltip会把这些实体转义成普通文本显示,开启escape: false后就能正常解析HTML内容了。
内容的提问来源于stack exchange,提问作者Natasha Garg
相关产品推荐
相关产品推荐

