React Native错误:"无法找到变量:TouchableHighlight"

时间:2017-04-13 19:21:17

标签: react-native expo touchablehighlight

我试图使用Expo在React Native中创建一个tic tac toe board。我使用TouchableHighlight使电路板可以触摸,这样我就可以添加X和O&#39。当应用程序运行时,我收到以下错误: "无法找到变量:TouchableHighlight" (Board.js 12:6)。

Board.js

import React, { Component } from 'react';
import { Text, View, Image, StyleSheet } from 'react-native';

export default class Board extends Component {

  _onPressButton() {
    console.log("you tapped the thing");
  }

  render() {
    return (
      <TouchableHighlight onPress={this._onPressButton}>
        <View style={styles.container}>
          <Image source = {require('./board.png')} style = {styles.table}/>
        </View>
      </TouchableHighlight>
    );
  }
}

const Xmark = (props) => (
  <View>
    <Image source = {require('./Xmark.png')} style = {styles.mark}/>
  </View>
);

const Omark = (props) => (
  <View>
    <Image source = {require('./Omark.png')} style = {styles.mark}/>
  </View>
);

const styles = StyleSheet.create({
  container: {
    flex: 6,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
  table: {
    height: 250,
    width: 250,
  },
  mark: {
    height: 25,
    width: 25,
  },
});

我需要导入其他东西吗?我查看了其他人的代码,但我没有看到任何明显不同的内容。感谢任何帮助。谢谢。

1 个答案:

答案 0 :(得分:8)

您只需要import { TouchableHighlight } from 'react-native'