【发布时间】:2021-01-01 12:48:10
【问题描述】:
所以下面的动态加载工作正常:
return React.lazy(() => import("./hotels/components/" + componentName));
以下不起作用:
const path = "./hotels/components/";
return React.lazy(() => import(path + componentName));
现在我认为它可能与缩小器有关,因为在它工作的情况下,“导入”在 vscode 中变为蓝色。如果它不起作用,“导入”是黄色的。
此外,当我针对它不起作用的情况进行编译时,我会收到以下警告:
Critical dependency: the request of a dependency is an expression
有人遇到过这个问题吗?
我尝试了这个类似问题的所有内容:
Webpack - Critical dependency: the request of a dependency is an expression
【问题讨论】:
-
@Viet Dinh 没用
-
这可能对你有帮助,参考here。
-
@Eric 是的,谢谢
标签: reactjs reflection