Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选取器不使用本机元素进行渲染_Javascript_Reactjs_Mobile_React Native - Fatal编程技术网

Javascript 选取器不使用本机元素进行渲染

Javascript 选取器不使用本机元素进行渲染,javascript,reactjs,mobile,react-native,Javascript,Reactjs,Mobile,React Native,我正在尝试将选择器元素(这样我可以有一个下拉菜单)添加到Header组件(Header是从react native elements库导入的),但是我看不到它,也看不到任何错误,如有任何帮助,将不胜感激 我已经成功地添加了一个矢量图标,所以我知道标题组件正在按预期工作,但仍然遵循文档,我看不到任何它 import React from 'react'; import { AppRegistry, StyleSheet, Text, View, Picker

我正在尝试将选择器元素(这样我可以有一个下拉菜单)添加到Header组件(Header是从react native elements库导入的),但是我看不到它,也看不到任何错误,如有任何帮助,将不胜感激

我已经成功地添加了一个矢量图标,所以我知道标题组件正在按预期工作,但仍然遵循文档,我看不到任何它

import React from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Picker,
    ListView
} from 'react-native';
import CoinCell from './js/Components/CoinCell/CoinCell';
import { Header } from 'react-native-elements';
import { getCryptocurrencyData } from './js/NetworkHandler'

export default class CoinCheckerRN extends React.Component {

  constructor(props) {
    super(props);
    const dataSource = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
    this.state = {
      dataSource: dataSource.cloneWithRows([]),
    };

    this._renderRow = this._renderRow.bind(this);
    this._getCoinData = this._getCoinData.bind(this);
    this._renderPicker = this._renderPicker.bind(this);
  }

  componentWillMount() {
    this._getCoinData();
  }

  _getCoinData() {
    getCryptocurrencyData().then(function(result) {

      const ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
      this.setState({
        dataSource: ds.cloneWithRows(result),
        jsonData: result
      });
    }.bind(this))
  }


  _renderRow(data) {
    return (
        <CoinCell coinName={data.name} coinPrice={data.price_gbp} coinPercentageChange={data.percent_change_24h}></CoinCell>        )
  }

  _renderPicker() {
    return (<Picker
        selectedValue={'test'}
        onValueChange={(itemValue, itemIndex) => this.setState({language: itemValue})}>
      <Picker.Item label="Java" value="java" />
    </Picker>)
  }

  _renderHeader() {
    return (
        <Header
            leftComponent={<Picker
                selectedValue={this.state.language}
                onValueChange={(itemValue, itemIndex) => this.setState({language: itemValue})}>
              <Picker.Item label="Wallet" value="key0" />
            </Picker>}
            rightComponent={{ icon: 'refresh', color: '#FFF' }}
            innerContainerStyles={{ backgroundColor: '#03A9F4'}}
            outerContainerStyles={{ backgroundColor: '#03A9F4'}}
        />)
  }

  render() {
    return (
        <View>
          {this._renderHeader()}
          <ListView
              enableEmptySections
              ref={'resultListView'}
              dataSource={this.state.dataSource}
              renderRow={this._renderRow}
              style={{paddingTop: 64}}
              renderSeparator={(sectionId, rowId) => <View key={rowId} style={styles.separator} />}
          />
        </View>
    );
  }
}
从“React”导入React;
进口{
评估学,
样式表,
文本,
看法
皮克,
列表视图
}从“反应本机”;
从“/js/Components/CoinCell/CoinCell”导入CoinCell;
从“react native elements”导入{Header};
从“./js/NetworkHandler”导入{getCryptocurrencyData}
导出默认类CoinCheckerRN扩展React.Component{
建造师(道具){
超级(道具);
const dataSource=new ListView.dataSource({rowHasChanged:(row1,row2)=>row1!==row2});
此.state={
dataSource:dataSource.cloneWithRows([]),用于,
};
this.\u renderRow=this.\u renderRow.bind(this);
this.\u getCoinData=this.\u getCoinData.bind(this);
this.\u renderPicker=this.\u renderPicker.bind(this);
}
组件willmount(){
这是。_getCoinData();
}
_getCoinData(){
getCryptocurrencyData().then(函数(结果){
const ds=new ListView.DataSource({rowHasChanged:(row1,row2)=>row1!==row2});
这是我的国家({
数据源:ds.cloneWithRows(结果),
jsonData:结果
});
}.绑定(本)
}
_renderRow(数据){
返回(
)
}
_renderPicker(){
返回(this.setState({language:itemValue})}>
)
}
_renderHeader(){
返回(
}
rightComponent={{图标:“刷新”,颜色:'#FFF'}}
innerContainerStyles={{backgroundColor:'#03A9F4'}}
outerContainerStyles={{backgroundColor:'#03A9F4'}}
/>)
}
render(){
返回(
{this.\u renderHeader()}
}
/>
);
}
}

我以前也遇到过类似的问题,定义选择器高度/宽度解决了这个问题。

您能给我们提供一个工作示例吗?你可以用一些东西来分享。你想举个什么样的例子?特定组件或整个屏幕?中,选择器在React库中似乎不可用,因此URL不会呈现它。将选择器高度/宽度作为样式对象添加到组件中,仍然没有成功。