fix: 修复动态导入esm模块时,ecStat.transform.histogram为空导致图表不显示的错误 #4904
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.
当模块采用
esm
时,由于动态import
ecStat
,但是未使用default,导致ecStat
为模块,ecStat.transform.histogram为空,会出现如下错误导致图表无法展示:正常代码应该为
ecStat.default.transform.histogram
,所以在动态导入后, 添加default
属性判断,如果default
不为空,将default
属性赋值给ecStat
对象。修改后的
react-amis-admin
示例代码,采用patch-package临时修复:https://github.com/iceqing/react-amis-admin/tree/vite
amis
ecStat
默认未使用default
错误示例代码,amis-esm-demo
项目:https://github.com/iceqing/amis-esm-demo
正常的页面展示效果(分支为vite),可以参考示例网站 https://amis.iceq.cc/