You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SharePoint Online JSON行格式化设置height属性提示不允许如何解决

SharePoint Online行格式化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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 16:48:05