【发布时间】:2018-04-14 15:44:05
【问题描述】:
我正在尝试将链接从另一个域重定向到设备的默认浏览器。
例如:
- 如果链接是http://domain.io,则留在WebView中;
- 如果链接是 http://domain.io/page,我们留在WebView;
- 如果链接是 http://mylink.io/,我们将用户重定向到默认浏览器 设备,然后我们离开 WebView。
我尝试了很多东西,但我仍然无法使其工作。我考虑将onNavigationStateChange 与链接一起使用。
感谢您的帮助。
import React from 'react';
import { StyleSheet, View, WebView } from 'react-native';
import { Constants } from 'expo';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<View style={styles.statusBar} />
<WebView
source={{uri: 'https://example.com'}}
renderError={() => alert('Merci de vérifier votre connexion Internet', 'Internet non disponible')}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
statusBar: {
backgroundColor: "#1D3B57",
height: Constants.statusBarHeight,
}
});
【问题讨论】:
标签: android ios react-native webview