diff --git a/src/components/Echarts/index.js b/src/components/Echarts/index.js index 6ce885f..3f3c071 100644 --- a/src/components/Echarts/index.js +++ b/src/components/Echarts/index.js @@ -1,9 +1,19 @@ import React, { Component } from 'react'; -import { WebView, View, StyleSheet } from 'react-native'; +import { WebView, View, StyleSheet, Platform } from 'react-native'; import renderChart from './renderChart'; import echarts from './echarts.min'; +import PropTypes from "prop-types"; export default class App extends Component { + static propTypes = { + ...WebView.propTypes, + option: PropTypes.object.isRequired, + width: PropTypes.number, + height: PropTypes.number, + backgroundColor: PropTypes.string, + onPress: PropTypes.func, + } + componentWillReceiveProps(nextProps) { if(nextProps.option !== this.props.option) { this.refs.chart.reload(); @@ -22,8 +32,9 @@ export default class App extends Component { backgroundColor: this.props.backgroundColor || 'transparent' }} scalesPageToFit={false} - source={require('./tpl.html')} + source={(Platform.OS == 'ios') ? require('./tpl.html') : {uri:'file:///android_asset/tpl.html'}} onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null} + {...this.props} /> );