javascript - 是否可以动态导入节点模块?
问题描述
我想知道是否可以动态导入通过 npm install 安装的模块。
就像是:
import("{ AsyncStorage } from react-native ???").then((module) => {
// do something with module
});
到目前为止,我发现的所有示例都只是导入自写的 ES 模块......
解决方案
你应该这样做
import ("react-native").then(({AsyncStorage: module}) => {
// Do something with the module
})
推荐阅读
- python - 如何在python中代表邮递员的pm.request.body
- rad-studio - 我在哪里可以找到 RAD Studio 10.4 安装后的 Vcl.ExtCtrls.pas 文件?
- java - 使用 Thymeleaf th:attr 和 th:attrappend 动态添加属性
- python - 如何在c ++中有效地从文件中拆分每一行
- python-3.x - 如何在保留标点符号的同时将文本拆分为句子?
- javascript - 通过 div 元素传递 ngmodel
- python - 从带有子文件夹的压缩文件夹中提取 .txt 文件,并使用文件夹位置重命名文件
- python-3.x - 无法在 Python 中调试异步函数
- visual-studio-code - Xdebug 远程主机 VSCode
- c# - C# 数据表值以适应并添加页码以进行打印