因此,我正在尝试使用胜利图表(https://formidable.com/open-source/victory),而不是仅仅使用webview,因为它们有一个本机实现。
但是,我尝试将该库与React Native Web一起使用,但它根本不起作用,我得到了以下错误:
/Users/myname/Desktop/Projects/myproject/Frontend/Expo/node_modules/victory-native/lib/components/victory-axis.js 10:22
Module parse failed: Unexpected token (10:22)
You may need an appropriate loader to handle this file type.
|
| export default class extends VictoryAxis {
> static defaultProps = Object.assign({}, VictoryAxis.defaultProps, {
| axisComponent: <LineSegment/>,
| axisLabelComponent: <VictoryLabel/>,我猜我需要使用两个“包装器”文件,Victory.js和Victory.web.js来导入。
到目前为止,我的Victory.web.js文件如下:
Victory = require('victory');
export default Victory;这不起作用。
我也尝试过:
import { VictoryPie } from 'victory';
export VictoryPie;这给了我一个错误:
/Users/myname/Desktop/Projects/myproject/Frontend/Expo/src/components/utility/Victory.web.js
SyntaxError: /Users/myname/Desktop/Projects/myproject/Frontend/Expo/src/components/utility/Victory.web.js: Unexpected token (3:17)
1 | import { VictoryPie } from 'victory';
2 |
> 3 | export VictoryPie;我只希望能够在React Native和React Native Web上使用这个库,而不会抛出错误。有没有办法做到这一点?
发布于 2020-07-11 03:57:58
我不确定这是否是最好的方法,但这种方法对我很有效:
export const VictoryPie = require('victory').VictoryPie;https://stackoverflow.com/questions/62841403
复制相似问题