zoukankan      html  css  js  c++  java
  • native-echarts 在安卓上无法显示出来

    1.native-echarts 的配置是百度echarts

    2.模拟器上试了很多次都显示不出来(具体不清楚,我的是这样)

    3.真机测试可以显示图表,以下是配置:

      a。将node_modules ative-echartssrccomponentsEcharts下的tpl.html复制到androidappsrcmainassets目录下,assets需要自己新建文件夹

      b。在node_modules ative-echartssrccomponentsEcharts下的index.js文件进行修改:

        

    import React, { Component } from 'react';
    import { WebView, View, StyleSheet, Platform } from 'react-native'; // 需要添加一个Platform
    import renderChart from './renderChart';
    import echarts from './echarts.min';


    export default class App extends Component {

    constructor(props) {
    super(props);
    this.setNewOption = this.setNewOption.bind(this);
    }


    componentWillReceiveProps(nextProps) {
    if(nextProps.option !== this.props.option) {
    this.refs.chart.reload();
    }
    }

    setNewOption(option) {
    this.refs.chart.postMessage(JSON.stringify(option));
    }

    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={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}
    />
    </View>
    );
    }
    }
  • 相关阅读:
    Leetcode86.分隔链表
    Leetcode39.组合总和
    Leetcode31.下一个排列
    剑指Offer35.复杂链表复制
    剑指Offer14-I.剪绳子
    剑指Offer38.字符串的排序
    Leetcode29.两数相除
    232. Implement Queue using Stacks
    程序员跳槽指南
    226. Invert Binary Tree
  • 原文地址:https://www.cnblogs.com/lude1994/p/10647842.html
Copyright © 2011-2022 走看看