fix: dialog.show method return close function #740
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题
原
Dialog.show
方法调用返回的destory
方法固定为noop
,不能按照预期行为工作:原因
调用
Dialog.show
时,return
的执行会优先于TempDialog
组件中方法的执行。原 destory 为基础类型,无法在调用时获取到最新的期望内容。修复方式
用
Map
存储 id-close 方法键值对,因为Map
是引用类型,故在使用方调用时,能根据 id 拿到最新且对应的销毁方法。其中 id 为
rv-dialog-root--${Date.now()}
,实际业务中可保证基本唯一。具体代码见 PR。