小编mdh*_*mil的帖子

React Native-调用AppRegistry.runApplication时出错

当我按照React Native入门页面中所述运行一个简单的“ AwesomeProject”应用程序时,该应用程序在Nexus6 API 23上运行,但显示错误 。我还尝试了以下方法来解决该错误:

  • adb反向tcp:8081 tcp:8081,但不起作用。

  • 在运行应用程序之前,在命令行中使用“ react-native start”,但在“ Loading Dependency Graph,done”完成后,它不显示任何内容。

  • 在Nexus5X API 25上运行它,但仍然发生错误。我该如何解决?

android react-native

5
推荐指数
1
解决办法
1319
查看次数

错误:未定义不是函数-React Native

我创建了一个简单的活动,在该活动中,如果您在圆形区域内按,则其中的文本应相应更改。该应用程序运行良好,但是当我在圆形区域内按时,出现错误消息“未定义不是函数(评估'this.setState({pressing:true});')”)。同样,圆形区域内的文本应首先设置,但为空。您可以在此处查看活动。下面还提供了代码:

import React, { Component } from "react";
import {
  StyleSheet,
  View,
  AppRegistry,
  Text,
  TouchableHighlight
} from "react-native";

class dhrumil extends Component {
  constructor(props) {
    super(props);
    this.state = { pressing: false };
  }
  _inPress() {
    this.setState({ pressing: true });
  }
  _outPress() {
    this.setState({ pressing: false });
  }
  render() {
    return (
      <View style={styles.mainContainer}>
        <TouchableHighlight
          onPressIn={this._inPress}
          onPressOut={this._outPress}
          style={styles.toucher}
        >
          <View style={styles.smallContainer}>
            <Text style={styles.texter}>
              {this.state.pressing ? "EEK" : "PUSH ME"}
            </Text>
          </View>
        </TouchableHighlight>
      </View>
    );
  }
}
var styles = …
Run Code Online (Sandbox Code Playgroud)

android react-native

4
推荐指数
1
解决办法
1万
查看次数

显示空白屏幕 - React Native

我写了一个简单的 React Native 应用程序,它将显示四个彩色矩形。该应用程序运行良好,但应用程序仅显示空白屏幕。我用正确显示的文本替换了渲染函数的内容。出了什么问题?

下面提供的代码:

index.android.js:

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

import Mainscreen from './components/screens/mainscreen.js';


 class styling extends Component {
  render() {
    return (
<View>
<Mainscreen />
</View>
);

  }
}
AppRegistry.registerComponent('styling', () => styling);
Run Code Online (Sandbox Code Playgroud)

主屏幕.js:

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

export default class Mainscreen extends Component{
  render(){
return (
<View style={styles.container}>
<View style={styles.smallContainer}>
  <View style={styles.above}>
    <View style={styles.leftAbove}></View>
    <View style={styles.rightAbove}></View>
  </View>
  <View style={styles.bottom}>
    <View style={styles.leftBottom}></View> …
Run Code Online (Sandbox Code Playgroud)

android react-native

3
推荐指数
1
解决办法
5254
查看次数

标签 统计

android ×3

react-native ×3