wepy icon indicating copy to clipboard operation
wepy copied to clipboard

wepy-redux中state更新后不能直接更新视图显示

Open thomasxlh opened this issue 6 years ago • 7 comments

@connect(
  {
    hisWords(state) {
      // return state.searchResultList.hisWords;  如果是执行这行的话,hisWords变化后,视图不会更新
      return [].concat(state.searchResultList.hisWords);  // 必须新开内存空间,否则更新hisWords后页面不会同步改变
    }
  }
)

hisWords作为参数会传递给子组件,然后用wx:for遍历显示。 请问下这里是为什么需要新建对象,是因为隐藏执行$apply()的原因么?

thomasxlh avatar Aug 01 '18 03:08 thomasxlh

异步action的话,确实是需要$aply的

JohnPion-Zhang avatar Aug 16 '18 00:08 JohnPion-Zhang

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. 因为这个 Issue 最近没有任何有效回复,所以被自动标记为了stale。 如果在未来7天依旧没有任何激活操作,那么该 Issue 将会被自动关闭。 感谢您的提问。

stale[bot] avatar Oct 15 '18 01:10 stale[bot]

this.$apply()试试

stale[bot] [email protected] 于2018年10月15日周一 上午9:03写道:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. 因为这个 Issue 最近没有任何有效回复,所以被自动标记为了stale。 如果在未来7天依旧没有任何激活操作,那么该 Issue 将会被自动关闭。 感谢您的提问。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Tencent/wepy/issues/1656#issuecomment-429679494, or mute the thread https://github.com/notifications/unsubscribe-auth/AYslxLsS1Tlk0z1axqZy1B3QhA5e3dmUks5uk97MgaJpZM4VpyIC .

JohnPion-Zhang avatar Oct 15 '18 07:10 JohnPion-Zhang

@thomasxlh 我这里同样问题,除了你给的方案,还有更好的没有

koaqiu avatar Dec 25 '18 08:12 koaqiu

不要直接操作state。不要直接操作state。不要直接操作state。

真不推荐,没有redux基础就去学习。这种二次封包。

https://segmentfault.com/q/1010000006144852

xiaoyuhao0716 avatar Jun 10 '19 09:06 xiaoyuhao0716

一定要深复制,一定要深复制,一定要深复制。两个小时的血泪史。

agoodcoolman avatar Oct 19 '19 01:10 agoodcoolman

@agoodcoolman 请问,你解决问题了吗?

kiradea avatar Jun 28 '20 08:06 kiradea