修改bug

This commit is contained in:
sgellar 2019-09-21 18:44:55 +08:00
parent 819233e4bb
commit 9ef48beaaa
2 changed files with 25 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{
"name": "native-echarts",
"version": "0.6.0",
"version": "0.7.0",
"description": "echarts for react-native",
"main": "src/index.js",
"directories": {

View File

@ -15,9 +15,17 @@ export default class App extends Component {
componentWillReceiveProps(nextProps) {
if(nextProps.option !== this.props.option) {
this.refs.chart.reload();
// this.refs.chart.reload();
if(Platform.OS === 'android'){
this.refs.chart.reload();
}else {
this.setNewOption(nextProps.option) ;
}
}
}
shouldComponentUpdate() {
return false ;
}
setNewOption(option) {
this.refs.chart.postMessage(JSON.stringify(option));
@ -25,21 +33,20 @@ export default class App extends Component {
render() {
return (
<View style={{flex: 1, height: this.props.height || 400,}}>
<WebView
ref="chart"
scrollEnabled = {false}
injectedJavaScript = {renderChart(this.props)}
style={{
height: this.props.height || 400,
backgroundColor: this.props.backgroundColor || 'transparent'
}}
scalesPageToFit={Platform.OS !== 'ios'}
originWhitelist={['*']}
source={{ html:getTpl() }}
onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null}
/>
</View>
<View style={{flex: 1, height: this.props.height || 400,}}>
<WebView
ref="chart"
scrollEnabled = {false}
injectedJavaScript = {renderChart(this.props)}
style={{
height: this.props.height || 400,
backgroundColor: this.props.backgroundColor || 'transparent'
}}
originWhitelist={['*']}
source={{ html:getTpl() }}
onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null}
/>
</View>
);
}
}