修改bug
This commit is contained in:
parent
819233e4bb
commit
9ef48beaaa
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "native-echarts",
|
"name": "native-echarts",
|
||||||
"version": "0.6.0",
|
"version": "0.7.0",
|
||||||
"description": "echarts for react-native",
|
"description": "echarts for react-native",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,21 @@ export default class App extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.setNewOption = this.setNewOption.bind(this);
|
this.setNewOption = this.setNewOption.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if(nextProps.option !== this.props.option) {
|
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) {
|
setNewOption(option) {
|
||||||
this.refs.chart.postMessage(JSON.stringify(option));
|
this.refs.chart.postMessage(JSON.stringify(option));
|
||||||
|
|
@ -25,21 +33,20 @@ export default class App extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1, height: this.props.height || 400,}}>
|
<View style={{flex: 1, height: this.props.height || 400,}}>
|
||||||
<WebView
|
<WebView
|
||||||
ref="chart"
|
ref="chart"
|
||||||
scrollEnabled = {false}
|
scrollEnabled = {false}
|
||||||
injectedJavaScript = {renderChart(this.props)}
|
injectedJavaScript = {renderChart(this.props)}
|
||||||
style={{
|
style={{
|
||||||
height: this.props.height || 400,
|
height: this.props.height || 400,
|
||||||
backgroundColor: this.props.backgroundColor || 'transparent'
|
backgroundColor: this.props.backgroundColor || 'transparent'
|
||||||
}}
|
}}
|
||||||
scalesPageToFit={Platform.OS !== 'ios'}
|
originWhitelist={['*']}
|
||||||
originWhitelist={['*']}
|
source={{ html:getTpl() }}
|
||||||
source={{ html:getTpl() }}
|
onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null}
|
||||||
onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null}
|
/>
|
||||||
/>
|
</View>
|
||||||
</View>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue