Astra GateEnglish

Table

v2 插件界面组件 Table(数据)的属性、子节点与示例

分组:数据 · 子节点:不接受子节点

属性

属性类型
columnsJSON
rowsJSON
rowKey字符串
sourceJSON
total数字
page数字
pageSize数字
sortJSON
selectionnone · single · multiple
selectedJSON
rowActionsJSON
bulkActionsJSON
expandedJSON
treeJSON
empty节点
loading布尔
dense布尔
stickyHeader布尔
onSort动作
onPage动作
onSelect动作
onRowPress动作
onRowAction动作
onBulkAction动作

另有所有组件都有的通用属性。动作类型的属性写动作名,或 { action, args }。

示例

组件画廊和两端比对用的就是这棵树:

代码json
{
  "type": "Table",
  "props": {
    "columns": [
      {
        "key": "model",
        "title": "Model",
        "sortable": true
      },
      {
        "key": "status",
        "title": "Status",
        "cell": {
          "type": "badge",
          "toneBy": {
            "ok": "success",
            "error": "danger"
          }
        }
      },
      {
        "key": "tokens",
        "title": "Tokens",
        "format": "tokens",
        "align": "end",
        "sortable": true
      },
      {
        "key": "cost",
        "title": "Cost",
        "format": "money",
        "align": "end"
      }
    ],
    "rows": [
      {
        "id": "r1",
        "model": "claude-sonnet-4",
        "status": "ok",
        "tokens": 18234,
        "cost": 42000000
      },
      {
        "id": "r2",
        "model": "gpt-5",
        "status": "error",
        "tokens": 912,
        "cost": 3000000
      },
      {
        "id": "r3",
        "model": "gemini-2.5-pro",
        "status": "ok",
        "tokens": 50211,
        "cost": 118000000
      }
    ],
    "rowKey": "id",
    "total": 3,
    "page": 1,
    "pageSize": 20,
    "sort": {
      "key": "tokens",
      "dir": "desc"
    },
    "onSort": "sort",
    "onPage": "page",
    "onRowPress": "open"
  }
}

画廊里另有这些状态:loading。