Compare commits
5 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
17054bc5a5 | |
|
|
425d304879 | |
|
|
d4214a14f2 | |
|
|
b9176c2157 | |
|
|
099fe797ad |
|
|
@ -26,6 +26,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/somonus/react-native-echarts#readme",
|
"homepage": "https://github.com/somonus/react-native-echarts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"echarts": "3.2.3"
|
"echarts": "3.2.3",
|
||||||
|
"react-native-webview":"13.8.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { WebView, View, StyleSheet, Platform } from 'react-native';
|
import { View, StyleSheet, Platform } from 'react-native';
|
||||||
|
import WebView from 'react-native-webview';
|
||||||
import renderChart from './renderChart';
|
import renderChart from './renderChart';
|
||||||
import echarts from './echarts.min';
|
import echarts from './echarts.min';
|
||||||
|
|
||||||
|
|
@ -11,7 +12,7 @@ export default class App extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
||||||
if(nextProps.option !== this.props.option) {
|
if(nextProps.option !== this.props.option) {
|
||||||
this.refs.chart.reload();
|
this.refs.chart.reload();
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +23,10 @@ export default class App extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const source = Platform.OS === 'ios'
|
||||||
|
? require('./tpl.html') // iOS使用require方式加载
|
||||||
|
: { uri: 'file:///android_asset/tpl.html' }; // Android从assets目录加载
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1, height: this.props.height || 400,}}>
|
<View style={{flex: 1, height: this.props.height || 400,}}>
|
||||||
<WebView
|
<WebView
|
||||||
|
|
@ -34,7 +39,7 @@ export default class App extends Component {
|
||||||
}}
|
}}
|
||||||
scalesPageToFit={Platform.OS !== 'ios'}
|
scalesPageToFit={Platform.OS !== 'ios'}
|
||||||
originWhitelist={['*']}
|
originWhitelist={['*']}
|
||||||
source={require('./tpl.html')}
|
source={source}
|
||||||
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>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { WebView, View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
|
import WebView from 'react-native-webview';
|
||||||
|
|
||||||
import { Container, Echarts } from './components'
|
import { Container, Echarts } from './components'
|
||||||
|
|
||||||
export default class App extends Component {
|
export default class App extends Component {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue