Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message Icon 跳变 #36

Closed
1 of 2 tasks
closertb opened this issue Jul 14, 2020 · 0 comments
Closed
1 of 2 tasks

Message Icon 跳变 #36

closertb opened this issue Jul 14, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@closertb
Copy link

问题描述

由于在Message组件中, iconType 使用了setData 来设置,所以当设置type 为非success 时,会出现icon 跳变,从默认的check_ 变为我们的设置值

  <am-icon className="am-icon icon-{{type}}" type="{{iconType}}" />
var TYPE_MAP = {
  success: 'check_',
  fail: 'close_',
  cancel: 'close_',
  info: 'help_',
  warn: 'warn_',
  waiting: 'time-5_'
};

onInit: function onInit() {
    this.setType(this.props.type);
  }

setType: function setType(type) {
      var realType = TYPE_MAP[type] || 'check_';
      this.setData({
        iconType: realType
      });
    }

复现步骤

message type设置为warn, 电脑反应速度低一些,即可看见icon 跳变

现在我们项目组是采用hack 的方式,将TYPE_MAP设置在了props 中,然后直接用js 对象的计算数据来做:

<am-icon className="am-icon icon-{{type}}" type="{{TYPE_MAP[type] || 'check_'}}" />

期待有更好的方式修复

demo 示例

截图

预期行为

环境信息

  • mini-ali-ui (px 版本扩展组件)
  • mini-ali-ui-rpx (rpx 版本扩展组件)
  • 组件库版本:
  • 设备机型:
  • 设备版本:
  • APP: 支付宝小程序
@linxz linxz added the bug Something isn't working label Aug 3, 2020
@linxz linxz closed this as completed in 20f6d55 Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants