Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
与以下 ES6 导入等效的 Node.js 'require' 是什么?
import RNFetchBlob from 'react-native-fetch-blob'
谢谢
require 中没有默认导出,因此您没有完全相同的导出。
当您只有一个值要导出时,使用节点模块的做法是使其成为模块导出:
module.exports = ...
在这种情况下,您可以使用
var RNFetchBlob = require('react-native-fetch-blob');
解决方案
我得到了它的工作:
var RNFetchBlob = require('react-native-fetch-blob').default;
有关更多详细信息,请查看此。