react-native - 文本和 TouchableOpacity 文本没有出现在直线上
问题描述
我试图在纯文本旁边加上一些可触摸的不透明度,但是,两个可触摸之间的纯文本与可触摸的文本不一致。请指导如何解决这个问题。
<Text style={{fontSize:10,textAlign:'center',}}>By clicking Sign up, you agree to Company's <TouchableOpacity ><Text style={{fontSize:10, color:'blue'}}>Terms of Service</Text></TouchableOpacity> and <TouchableOpacity><Text style={{fontSize:10, color:'blue'}}>Privacy Policy.</Text></TouchableOpacity></Text>
解决方案
不需要,touchableopacity
因为Text
有onPress
道具。
<Text style={{fontSize:10,textAlign:'center'}}>
By clicking Sign up, you agree to Companys
<Text
onPress={() => alert("Terms of Service is clicked")}
style={{fontSize:10, color:'blue'}}>
Terms of Service
</Text>
and
<Text
onPress={() => alert("Privacy Policy is clicked")}
style={{fontSize:10, color:'blue'}}>
Privacy Policy.
</Text>
</Text>
推荐阅读
- reactjs - 如何使用 React 创建可再分发的小部件
- python - 按熊猫系列中的第二列排序
- monitoring - 如何在 Grafana 中使用动态间隔测量吞吐量
- reactjs - 如果在 react slick 中的当前幻灯片之前或之后没有可用的幻灯片,则禁用 Prev 或 Next 按钮。(上一个下一个方法)
- python - 尝试收集 API 数据并发送到本地 mysql
- regex - RegEx如何阻止字符串中数字和字母的混合
- django - 测试 Django 视图时出现断言错误
- python-3.x - pip安装命令如何解决
- jquery - 使用 .each() 计算循环内的字段
- php - 在 Laravel 5 中为使用 json 方法链接的响应助手添加宏时出错