我想向我的webview中注入一些JavaScript代码,我想更改h1元素的颜色,但这在IOS上不起作用,这是我的代码:
constructor(props) {
super(props);
this.state = {
webViewLoaded: true,
showAdInter : true,
url : 'https://www.w3schools.com/jsref/met_document_getelementsbyclassname.asp'
}
}
jsCode(){
let linn ="document.querySelector('h1').style.color='blue';";
return linn;
}
render() {
const { container, webView, loadingWeb, SplachImage, TopButton, TopButtonText } = styles;
const { webViewLoaded, canGoBack } = this.state;
return (
<View style={container}>
<WebView
source={{uri: this.state.url}}
javaScriptEnabled={true}
domStorageEnabled={true}
injectedJavaScript={'this.jsCode.bind(this)'}
/>
</View >
);
}
}
请帮助我找出为什么它不能在IOS上运行