Skip to content

Conversation

@0x1306a94
Copy link
Contributor

  • 期望 QMUIAlertController 能够完全按照添加顺序布局按钮。

  • 虽然提供了 orderActionsByAddedOrdered 属性,但仍然存在以下问题:

    • 取消按钮(QMUIAlertActionStyleCancel)始终会被放置在最后,这与期望的完全按添加顺序布局不符。
    • 在水平布局且只有两个按钮时,取消按钮又会被放置在左侧,导致布局行为不一致。
  • Alert 按钮的文本样式可以通过全局的 alertButtonAttributesalertDestructiveButtonAttributesalertCancelButtonAttributes 进行配置。

  • 但产品需求经常变化,有时要求取消按钮在左侧,有时又要求在右侧,缺乏灵活性。

  • 如果 QMUIAlertController 可以完全按照添加顺序布局按钮,开发者只需选择合适的 QMUIAlertActionStyle 并控制添加顺序,即可灵活满足各种布局需求,无需进行额外的全局样式调整。 这样可以大大提高开发效率和布局的灵活性。

@MoLice
Copy link
Collaborator

MoLice commented Aug 19, 2025

没必要,用 orderActionsByAddedOrdered 不能满足需求吗?你只要不添加 cancel action 就行了。

@0x1306a94
Copy link
Contributor Author

@MoLice 比如和设计规范了如下,然后在全局配置好了 alertButtonAttributes alertDestructiveButtonAttributes alertCancelButtonAttributes

  • Default 黑色
  • Destructive 红色
  • Cancel 蓝色

但是产品要求,有的场景 Cancel 在左边 有的又要求 Cancel 在右边。 想利用全局配置,那么就无法灵活的控制 Cancel 的位置
要么就是在用的地方,额外多写点代码来单独配置Action 的 buttonAttributes

@0x1306a94 0x1306a94 closed this Nov 4, 2025
@0x1306a94 0x1306a94 changed the title QMUIAlertController 支持严格按照添加的Action顺序排列 QMUIAlertController Alert样式Actions 布局错误 Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants