除了默认的 3 之外,我正在尝试为松弛按钮设置其他样式:
- primary (green)
- danger (red)
- default (grey)
我想为按钮设置其他颜色,例如orange
。
我知道可以通过指定十六进制代码为附件设置自定义颜色。
有没有办法为松弛按钮指定自定义颜色?
这是我尝试过的:
{
"text": "Please rate this trip.",
"attachments": [
{
"callback_id": "rate_trip",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "yes",
"text": "yes :thumbsup:",
"type": "button",
"value": "yes",
"style": "primary"
},
{
"name": "no",
"text": "no :thumbsdown:",
"type": "button",
"value": "no",
"style": "danger"
},
// I'd like to make the style for this to be orange but it defaults to grey.
{
"name": "maybe",
"text": "maybe :neutral_face:",
"type": "button",
"value": "maybe",
"style": "#FFA500",
}
}
]
}
]
}
最佳答案
没有。 Slack 不允许您为按钮使用自定义颜色。正如您所提到的,您只能使用“样式”(在 style
字段中)为按钮着色,并且仅限于 default
、primary
和 危险
。
参见 here有关此主题的官方文档。
关于node.js - 如何使用 slack API 为 slack 上的按钮设置颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55417667/