描述

设置选项知识库。
系统运行过程中,只需添加1次,所有文档通用

接口

bool SetOptions(const char* optionsJson)
试一试
HTML
|
运行代码
thinkEditor.SetOptions([
    {
      optionClass: "系统",
      optionId: "性别",
      items: [
        {
          id: "man",
          groupId: "",
          weight: 1.0,
          content: "男性",
        },
        {
          id: "woman",
          groupId: "",
          weight: 1.0,
          content: "女性",
        },
        {
          id: "unkown",
          groupId: "",
          weight: 1.0,
          content: "未知性别",
        }
      ]
    }
  ]);

参数

optionsJson

参数名 必填 类型 说明 备注
optionClass string 选项类
optionId string 选项组

optionsJson格式如下

[
    {
        "optionClass": "系统",
        "optionId": "属地",
        "items": [
            {
                "id": "1",
                "groupId": "",
                "weight": 1.00,
                "content": "本县区"
            },
            {
                "id": "2",
                "groupId": "",
                "weight": 1.00,
                "content": "本市其他县区"
            },
            {
                "id": "3",
                "groupId": "",
                "weight": 1.00,
                "content": "本市其他县区"
            }
        ]
    }
]

items

参数名 必填 类型 说明 备注
id string 选项itemId 必填,且一个items内必须唯一。
groupId string 分组id
weight float 权值
content string 选项显示内容

返回值

类型 说明 备注
bool 设置是否成功 1:成功 0:失败
文档更新时间: 2025-04-17 00:13   作者:admin