SharePoint Online超链接列格式化:为空时显示NA的实现问题
修改后的列格式化代码如下,可实现空值显示“NA”、有超链接时显示可点击的“View MSA”:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "a", "attributes": { "href": "@currentField", "target": "_blank" }, "txtContent": "View MSA", "visible": "=if(@currentField, true, false)" }, { "elmType": "span", "txtContent": "NA", "visible": "=if(@currentField, false, true)" } ] }
逻辑说明:
- 用
div作为外层容器,包裹两个子元素:超链接标签a和文本标签span - 通过
visible属性结合if表达式判断列值状态:- 当超链接列有值时,
a标签可见,显示可点击的“View MSA” - 当列值为空时,
span标签可见,显示“NA”
- 当超链接列有值时,
内容的提问来源于stack exchange,提问作者Thebat276
相关产品推荐
相关产品推荐

