SharePoint Online JSON行格式化设置height属性提示不允许如何解决
报错根因
height属于CSS样式属性,不能定义在attributes节点下。SharePoint行格式化的JSON规范中,attributes节点仅用于存放HTML原生属性、系统预定义类名等配置,所有CSS样式参数必须放在同级的style节点中才能生效。
正确修改方式
你需要将原来attributes节点下的类名配置删除,新增同级的style节点,将height参数写入该节点即可。如果需要保留原来的红色背景效果,可以同时在style节点中添加background-color配置。
修改后的完整配置代码
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json", "hideSelection": true, "hideColumnHeader": true, "rowFormatter": { "elmType": "div", "attributes": { "class": "sp-row-card" }, "children": [ { "elmType": "div", "style": { "text-align": "left" }, "children": [ { "elmType": "div", "style": { "height": "50px", "background-color": "#ff0000" }, "txtContent": "[$MyVal]" }, { "elmType": "div", "style": { "height": "50px", "background-color": "#ff0000" }, "txtContent": "[$MyVal]" } ] } ] } }
若不需要保留红色背景,直接删除style节点中的background-color配置即可。
内容的提问来源于stack exchange,提问作者p whelan
相关产品推荐
相关产品推荐

