我有一个世博会项目,我在其中添加了胜利原生库。在为web构建时,Webpack抱怨缺少加载器。这些错误如下所示,出现在此特定库中的所有文件中
./node_modules/victory-native/src/components/victory-clip-container.js 10:22
Module parse failed: Unexpected token (10:22)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| export default class extends VictoryClipContainer {
> static defaultProps = Object.assign({}, VictoryClipContainer.defaultProps, {
| groupComponent: <G />,
| rectComponent: <Rect />,如何添加正确的加载器?我在babel配置中添加了什么吗?或者我应该重写webpack的配置?巴别塔目前只使用babel-preset-expo
发布于 2021-11-04 15:45:44
您不能将胜利原生导入用于web,也不能将胜利导入用于react原生。
我通过创建一个名为victory.native.ts和victory.ts的文件解决了这个问题,该文件包含所有必要的导入。
victory.native.ts:
import * as Victory from 'victory-native'victory.ts:
import * as Victory from 'victory'现在您可以在web和应用程序中导入victory.ts。
https://stackoverflow.com/questions/69839366
复制相似问题