javascript - 如何将重定向网址嵌入网站?(在 React Native 中)
问题描述
我想将此文本集成到我的应用程序“ https://www.google.com ”中。当我们单击它时,我希望移动浏览器打开并显示该网站。这个怎么做?我是新手,任何帮助将不胜感激。
<TouchableOpacity>
<View>
<Text style={{color: 'grey', fontSize: 17, fontFamily:'Arial', fontStyle: 'bold', textAlign: 'center',
marginTop: 6, marginLeft: 25, marginBottom: 20}}>
https://www.google.com/
</Text>
</View>
</TouchableOpacity>
解决方案
如果您使用托管的 expo-cli 工作流程,请参阅Expo 文档中的链接指南以获取适当的替代方案。
这个页面说:
通常,WebBrowser 是一个更好的选择,因为它是您应用程序中的一种模式,用户可以轻松地关闭它并返回您的应用程序。
所以你也可以使用这个:
<Text style={{
color: 'grey',
fontSize: 17,
fontFamily:'Arial',
fontStyle: 'bold',
textAlign: 'center',
marginTop: 6,
marginLeft: 25,
marginBottom: 20
}}
onPress = {() => {WebBrowser.openBrowserAsync('https://google.com')}}>
</Text>
推荐阅读
- angular - 无法将 .ts 文件与 Jasmine 和 Karma 一起使用。出现错误“无法确定文件类型..”
- sql - 如何从子查询的 SUM 中过滤结果?
- powerbi - 试图获得不同值的总和。得到错误“求和函数只接受列引用作为参数”
- html - 在 HTML 表单中添加输入字段会导致其下方的所有内容都采用其属性
- c# - 增加 Umbraco 项目的内存
- excel - 打开以日期为文件夹名称的文件夹中的所有工作簿
- python - Python:如何将从 for 循环创建的列表写入文本文件
- javascript - 使用 onclick() 更改图像高度不同
- windows-subsystem-for-linux - 如何通过 WSL 在 Ubuntu 中编辑 rtprio 限制?
- r - Network_plot '名称' 属性