配置脚本中所有组件,完整组件例子,包含所有参数,罗列出来

已存档
兔如花
9
· 2 个月前

回答

Hamibot AI
1
· 2 个月前

以下是Hamibot脚本配置中所有可用组件的完整示例,包含全部参数:

[
  {
    "label": "文本输入",
    "name": "text_input",
    "type": "text",
    "placeholder": "请输入内容",
    "help": "这是文本输入框的说明",
    "validation": "required",
    "validation-name": "必填项",
    "value": "默认值"
  },
  {
    "label": "多行文本",
    "name": "textarea",
    "type": "textarea",
    "rows": 4,
    "placeholder": "多行输入内容..."
  },
  {
    "label": "数字输入",
    "name": "number_input",
    "type": "number",
    "min": 0,
    "max": 100,
    "step": 1
  },
  {
    "label": "滑块",
    "name": "slider",
    "type": "slider",
    "min": 0,
    "max": 100,
    "step": 5,
    "value": 50
  },
  {
    "label": "开关",
    "name": "switch",
    "type": "switch",
    "value": true
  },
  {
    "label": "单选",
    "name": "radio",
    "type": "radio",
    "options": [
      {"label": "选项1", "value": "opt1"},
      {"label": "选项2", "value": "opt2"}
    ],
    "value": "opt1"
  },
  {
    "label": "多选",
    "name": "checkbox",
    "type": "checkbox",
    "options": [
      {"label": "选项A", "value": "a"},
      {"label": "选项B", "value": "b"}
    ],
    "value": ["a"]
  },
  {
    "label": "下拉选择",
    "name": "select",
    "type": "select",
    "options": [
      {"label": "选项一", "value": 1},
      {"label": "选项二", "value": 2}
    ],
    "value": 1
  },
  {
    "label": "颜色选择",
    "name": "color",
    "type": "color",
    "value": "#FF0000"
  },
  {
    "label": "时间选择",
    "name": "time",
    "type": "time",
    "value": "09:00"
  },
  {
    "label": "日期选择",
    "name": "date",
    "type": "date",
    "value": "2025-06-25"
  }
]

在脚本中使用这些配置的代码示例:

// 文档地址 https://docs.hamibot.com/
const config = hamibot.env;
toastLog('当前配置: ' + JSON.stringify(config));
hamibot.exit();

注意:

  1. 带有value参数的组件会显示默认值
  2. validation支持"required"、"email"、"url"等验证规则
  3. 选择类组件(options/radio/checkbox/select)需要提供选项数组
ℹ️ 本回答由 AI 生成,内容仅供参考