Open jichangshuai opened 6 years ago
src/Echarts/index.js内容如下:
import React, { Component } from 'react'; import { WebView, View, StyleSheet, Platform } from 'react-native'; import renderChart from './renderChart'; import echarts from './echarts.min';
export default class App extends Component {
// 预防过渡渲染 shouldComponentUpdate(nextProps, nextState) { const thisProps = this.props || {} nextProps = nextProps || {} if (Object.keys(thisProps).length !== Object.keys(nextProps).length) { return true } for (const key in nextProps) { if (JSON.stringify(thisProps[key]) != JSON.stringify(nextProps[key])) { return true } } return false }
componentWillReceiveProps(nextProps) { if(nextProps.option !== this.props.option) { // this.refs.chart.reload(); // 解决数据改变时页面闪烁的问题 this.refs.chart.injectJavaScript(renderChart(nextProps)) } }
render() { const source = (Platform.OS === 'ios') ? require('./tpl.html') : ({uri: 'file:///android_asset/tpl.html'}); const IOSFit = (Platform.OS === 'ios') ? false : true; 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: 'rgba(0,0,0,0)' }} scalesPageToFit={IOSFit} source={source} /> ); } }
华为mate8目前也会出现此种情况
这2中机型,都是初次进入的时候可以显示,当进行了OCR(拍照或者扫一扫)识别后,就不显示了,是拍照之后找不到模板了吗
@jichangshuai 你好 ,我这边也出现这种情况 ,请问你找到解决方法了吗
src/Echarts/index.js内容如下:
import React, { Component } from 'react'; import { WebView, View, StyleSheet, Platform } from 'react-native'; import renderChart from './renderChart'; import echarts from './echarts.min';
export default class App extends Component {
componentWillReceiveProps(nextProps) { if(nextProps.option !== this.props.option) { // this.refs.chart.reload(); // 解决数据改变时页面闪烁的问题 this.refs.chart.injectJavaScript(renderChart(nextProps)) } }
render() { const source = (Platform.OS === 'ios') ? require('./tpl.html') : ({uri: 'file:///android_asset/tpl.html'}); const IOSFit = (Platform.OS === 'ios') ? false : true; 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: 'rgba(0,0,0,0)' }} scalesPageToFit={IOSFit} source={source} /> ); } }