javascript - react native : <Text> won't render if placed inside <TouchableHighlight>

标签 javascript react-native

在下面的代码中:

'use strict';

var React = require('react-native'),

{
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Component,
  NavigatorIOS
} = React,

styles = StyleSheet.create({
  container: {
    padding: 30,
    marginTop: 65,
    alignItems: 'center'
  },
  button: {
    height: 36,
    flex: 1,
    flexDirection: 'row',
    backgroundColor: '#48BBEC',
    borderColor: '#48BBEC',
    borderWidth: 1,
    borderRadius: 8,
    marginBottom: 10,
    alignSelf: 'stretch',
    justifyContent: 'center'
  },
  buttonText: {
    fontSize: 18,
    color: 'white',
    alignSelf: 'center'
  },
  text: {
    color: 'black',
    backgroundColor: 'white',
    fontSize: 30,
    margin: 80
  }
})

class Login extends Component {
  render() {
    return (
    /*<TouchableHighlight
      style={styles.button}
      underlayColor='#99d9f4'>*/
      <Text style={styles.text}>Login with Google</Text>
    /*</TouchableHighlight>*/
    )
  }
}

module.exports = Login

<Text>仅当周围的 <TouchableHighlight> 时才会呈现登录名被注释掉了。我做错了什么?

最佳答案

您需要导入“TouchableHighlight”。 将 TouchableHighlight 添加到您的需求列表中。

var React = require('react-native'),

{
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Component,
  NavigatorIOS,
  TouchableHighlight
} = React,

关于javascript - react native : <Text> won't render if placed inside <TouchableHighlight>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29439759/

相关文章:

javascript - 进度条加载后加载页面

reactjs - React 导航 TabBarIcon 未出现

reactjs - React 导航栏标题左侧有边距

node.js - React Native - 运行 "npm start"和 "react-native run-android"时出错

ios - pod install 正在安装在不同的文件夹中

javascript - Mongo聚合管道更新或推送

javascript - Typescript 数组语法 MyModel[] 或 [MyModel]

javascript - 调试器没有单步执行 Javascript 中的 window.close

javascript - jQuery 自定义内容滚动器不适用于 Bootstrap 表响应

javascript - React-Native将从 url 获取的 JSON 对象分配给变量