我有一个Webview,仅当它们包含google.com作为主机时,我才允许加载页面,但是我不知道如何实现该代码, 你能帮我吗
.
答案 0 :(得分:1)
您想将#include <type_traits>
#include <iostream>
int main()
{
float test [3] = {1, 2, 3};
std::cout
<< std::extent<decltype(test)>::value
<< '\n';
}
属性与检查网址域的函数一起使用。如果不允许使用该网址,请改为显示错误。
onNavigationStateChange
webviewState对象原型:
_onNavigationStateChange(webViewState){
console.log(webViewState.url)
}
答案 1 :(得分:0)
您可以使用react-native的条件渲染。
类似的东西:
render(){
return yourCondition ? <WebView/> : <AnotherView/>
}
只需检查条件中的主机名即可。
答案 2 :(得分:0)
您应该首先验证要获取的主机。之后,您将根据结果返回。
类似这样的东西:
render(){
const allowHost = "google.com";
const verifyHost = (url, allowHost) => {
let host;
// Do logic to verify if the url host is equal to the allowHost...
...
return host === allowHost;
}
return verifyHost(url, allowHost) ? <WebView/> : <View>This URL is not allowed.</View>
}