使用 babel 编译 ES6 文件并将其转换为 CommonJS 格式的文件,以使 applyMiddleware 启作用。例如,在使用 Redux 进行开发时,可添加以下配置到 .babelrc 文件中:
{
"presets": ["@babel/preset-env"],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-transform-modules-commonjs"
]
}
其中,@babel/plugin-transform-runtime 为避免重复编译引入的模块而安装的插件,@babel/plugin-transform-modules-commonjs 则是将 ES6 模块转换为 CommonJS 模块的插件。这样,即可在 ES6 文件中使用 applyMiddleware 等函数。
上一篇:Applymatchfilterbutignorefirstelement
下一篇:Applymutateandstoreresultsinanestedtibblecolumninthedataframe