2017-11-09 8 views
0
constructor(props) { 
    super(props); 
    this.state = { 
     isLoading: true, 
     search:'', 
    }; 
    } 

    componentDidMount(){ 
    var url = 'url='+this.state.search; 
    axios.get(url) 
     .then(response =>this.onResponse(response.data)); 
    } 

    onResponse(gelen){ 
    this.setState({ 
     isLoading:false, 
     veri:gelen, 
    }); 
    console.log(this.state.veri); 
    } 

    render() { 
    if (this.state.isLoading) { 
     return (
     <View style={{flex: 1, paddingTop: 20}}> 
      <ActivityIndicator /> 
     </View> 
    ); 
    } 
    return(
     <View style={styles.container}> 
     <TextInput 
      style={{height: 40, borderColor: 'gray', borderWidth: 1}} 
      onChangeText = {(search) => this.setState({search})} 
      placeholder="Welcome"> 
     </TextInput> 
     </View> 
    ); 
    } 

リアクションネイティブ検索は変更されますが、URLは変更や更新の方法を変更しないでください。 検索ページを作りたかったので、このような試みをしましたが、URLの最後にデータが入ってからデータエントリを追加できませんでした。Axios URLを変更するには?

答えて

1

あなたがする必要があり、火災セット検索状態ともあなたが好きそれを行うことができますaxios

火災:

<TextInput 
    style={{height: 40, borderColor: 'gray', borderWidth: 1}} 
    onChangeText = {(search) => this.searchData(search)} 
    placeholder="Welcome"> 
</TextInput> 

searchData(search) { 
    this.setState({search}); 
    var url = 'url='+search; 
    axios.get(url).then(response => this.onResponse(response.data)); 
} 
関連する問題