json 如何格式化Sharepoint列表以在图像顶部添加链接

nzkunb0c  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(102)

我想编辑sharepoint列表显示图像,并超链接到另一个网站(最终,使图像可点击-一旦点击它会移动到其他页面的用户)Something like on this picture
我设法格式列表显示图片如下,但我不能添加超链接或使其可点击
current

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
  "hideSelection": true,
  "width": "355",
  "height": "355",
  "formatter": {
    "elmType": "div",
    "children": [
      {
        "elmType": "div",
        "style": {
          "display": "inline-block",
          "min-width": "355px",
          "min-height": "355px",
          "margin-right": "10px",
          "box-shadow": "2px 2px 4px darkgrey"
        },
        "children": [
          {
            "elmType": "img",
            "attributes": {
              "src": "[$Image.serverRelativeUrl]"
            },
            "style": {
              "height": "360px",
              "max-width": "360px"
            }
          },
      {
        "elmType": "a",
        "txtContent": "Click here",
        "style": {
          "border": "none",
          "padding-top": "0px",
          "color": "#0078d7",
          "padding-left": "0px",
          "text-align": "center",
          "cursor": "pointer"
            },
            "attributes": {
              "target": "_blank",
              "href": "[$Link]"
            }
          }
        ]
      }
    ]
  }
}

字符串
我查阅了文档,但没有任何帮助

mnowg1ta

mnowg1ta1#

你可以试试这个JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
  "hideSelection": true,
  "width": "355",
  "height": "355",
  "formatter": {
    "elmType": "div",
    "children": [
      {
        "elmType": "div",
        "style": {
          "display": "inline-block",
          "min-width": "355px",
          "min-height": "355px",
          "margin-right": "10px",
          "box-shadow": "2px 2px 4px darkgrey"
        },
        "children": [
          {
            "elmType": "a",
            "attributes": {
              "target": "_blank",
              "href": "[$Link]"
            },
            "children": [
              {
            "elmType": "img",
            "attributes": {
              "src": "[$Image.serverRelativeUrl]"
            },
            "style": {
              "height": "360px",
              "max-width": "360px"
            }
          }
            ]
          }
        ]
      }
    ]
  }
}

字符串
以下是我这边的结果:Result

相关问题