0
我開發的一個應用程序的WebView反應母語,我面臨一個問題:點擊一個按鈕不會顯示
我想,當我點擊一個按鈕(或者直接查看按鈕所在的位置)WebView將顯示在屏幕上,並打開直接傳入參數的鏈接。 但沒有任何反應。
這裏是我的代碼:
return (
<ScrollView style={[style.case1]} refreshControl={<RefreshControl refreshing={this.state.refreshing} onRefresh={this.handleRefresh} />} >
{
this.state.orders.map(function (order) {
let a = _this.getPosts(order);
let Final = _this.splitString(a.message," ");
return (
<View style={[style.case2]} key={a.message} >
<Couleur couleur={Final[4]} />
<Text style={[style.Nom]} >Nom : {Final[1]}</Text>
<Text style={[style.Nom]} >Numéro de build : {Final[2]}</Text>
<Button onPress={<Web url={Final[3]} />} title="Click"/>
</View>
);
})}
</ScrollView>
);
而且網頁視圖類:
import React, {Component} from "react";
import {WebView} from "react-native";
export default class Web extends Component {
constructor(props){
super(props);
}
render() {
let uri = this.props.url;
return(
<WebView
ref={(ref) => {this.webview = ref;}}
source={{uri}}
style={{marginTop:20}}
/>
)
}
}
,我得到這個錯誤:
「對象不是一個函數(計算「這個.props.onPress(e)')
如果有人幫助我,我會很開心! :)
有你試圖改變這樣的'onPress = {()=>收益 }'? –
我輸入解決方案時出錯,但如果我刪除'返回',我現在沒有任何錯誤。 –
但是我仍然沒有顯示WebView。感謝您的幫助 –