dva icon indicating copy to clipboard operation
dva copied to clipboard

app.unmodel 之后, dynamic 不会重复注册model

Open zzh-a opened this issue 8 years ago • 4 comments

Code to reproduce the issue: (请提供可复现的代码或者步骤)

1,dynamic 注册一个model, 2,离开该组件时注销

 componentWillUnmount() {
    this.context.app.unmodel('direct');
 }

3, 在进入该路由时 model 不会重复注册

建议: dynamic.js中 用本地的cache 去判断是否加载model,我建议应该实时从app中判断,这样会更符合预期。

Expected behavior: (预期的正常效果)

可以重复注册已 经注销的model

Actual behavior: (实际效果)

不会重复注册

Versions of packages used: (哪个库的哪个版本出现的问题)

[email protected]

zzh-a avatar Jan 24 '18 12:01 zzh-a

请问有解决方法了吗

qinhuaihe avatar Feb 27 '18 05:02 qinhuaihe

@sorrycc 是不是可以在Dynamic Wrapper 中 componentWillUnmount 这个钩子里自动注销model?

zjsth92 avatar Aug 09 '18 00:08 zjsth92

确实应该从app._models里去判断model是否已加载,我按楼主的建议修改了 dynamic.js的registerModel方法,可以实现unmodel后再次动态加载model

Crown1991 avatar Nov 01 '18 07:11 Crown1991

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.

stale[bot] avatar Mar 14 '19 07:03 stale[bot]