Reactjs 意外标记,应为“}”&引用;在我的书柜里

Reactjs 意外标记,应为“}”&引用;在我的书柜里,reactjs,react-native,react-native-ios,Reactjs,React Native,React Native Ios,请容忍我,因为我对这一切都是新的,这是我第一个张贴的问题!我正在尝试用注册按钮设置一个简单的“欢迎屏幕”,并且正在学习ios/应用程序开发过程/react native和javascript。有人能解释一下为什么第68行有错误吗?我以前遇到过这个错误,我认为这可能是因为我在类之外“调用”样式,但我相信这只是一个问题,如果这是一个函数而不是一个类? 错误读取:未能加载包(?)? platform=ios&dev=true&minify=false)错误:(SyntaxError:/Users/na

请容忍我,因为我对这一切都是新的,这是我第一个张贴的问题!我正在尝试用注册按钮设置一个简单的“欢迎屏幕”,并且正在学习ios/应用程序开发过程/react native和javascript。有人能解释一下为什么第68行有错误吗?我以前遇到过这个错误,我认为这可能是因为我在类之外“调用”样式,但我相信这只是一个问题,如果这是一个函数而不是一个类? 错误读取:未能加载包(?)? platform=ios&dev=true&minify=false)错误:(SyntaxError:/Users/name/appname/App.js:意外标记,应为“}”(68:13)

type Props={};
导出默认类应用程序扩展组件{
render(){
const styles=StyleSheet.create({
容器:{
弹性:1,
辩护内容:“中心”,
对齐项目:“中心”,
背景颜色:“F5FCFF”
},
欢迎:{
尺寸:20,
textAlign:“居中”,
差额:10
},
说明:{
textAlign:“居中”,
颜色:“333333”,
marginBottom:10
},
按钮:{
对齐项目:“中心”,
背景颜色:“蓝色”,
宽度:100,
填充:10
},
计数文本:{
填充:20,
颜色:“FF00FF”
}
});
返回(
欢迎来到P2P区块链!
要开始,请单击下面的!
在这里注册!
{this.state.count!==0?this.state.count:null}
);
}
}
从“React”导入React,{Component};
从“react native”导入{View,StyleSheet,TouchableHighlight,Text};
类型Props={};
类应用程序扩展组件{
建造师(道具){
超级(道具);
此.state={
计数:10,
};
}
render(){
返回(
欢迎来到P2P区块链!
要开始,请单击下面的!
在这里注册!
{this.state.count!==0?this.state.count:null}
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
辩护内容:“中心”,
对齐项目:“中心”,
背景颜色:“F5FCFF”
},
欢迎:{
尺寸:20,
textAlign:“居中”,
差额:10
},
说明:{
textAlign:“居中”,
颜色:“333333”,
marginBottom:10
},
按钮:{
对齐项目:“中心”,
背景颜色:“蓝色”,
宽度:100,
填充:10
},
计数文本:{
填充:20,
颜色:“FF00FF”
}
});
导出默认应用程序;

您的
容器后面有一个
{
,您在
按钮和
countText中使用样式后缺少了
,并且在JSX末尾没有关闭
标记。即使进行了这些更正,问题仍然没有得到解决-我也很抱歉,逗号和句点是在这里重写代码造成的。没关系。到底是什么错误你明白了吗?我会附上错误信息~
type Props = {};

export default class App extends Component<Props> {
  render() {
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "#F5FCFF"
      },
      welcome: {
        fontSize: 20,
        textAlign: "center",
        margin: 10
      },
      instructions: {
        textAlign: "center",
        color: "#333333",
        marginBottom: 10
      },
      button: {
        alignItems: "center",
        backgroundColor: "blue",
        width: 100,
        padding: 10
      },
      countText: {
        padding: 20,
        color: "#FF00FF"
      }
    });
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to P2P Blockchain!</Text>
        <Text style={styles.instructions}>To get started, click below!</Text>
        <View style={styles.container}>
          <TouchableHighlight style={styles.button} onPress={this.onPress}>
            <Text> Sign Up Here! </Text>
          </TouchableHighlight>
          <View style={[styles.countContainer]}>
            <Text style={[styles.countText]}>
              {this.state.count !== 0 ? this.state.count : null}
            </Text>
          </View>
        </View>
      </View>
    );
  }
}
import React, { Component } from 'react';
import { View, StyleSheet, TouchableHighlight, Text } from 'react-native';

type Props = {};

class App extends Component<Props> {
    constructor(props) {
        super(props);
        this.state = {
            count: 10,
        };
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.welcome}>Welcome to P2P Blockchain!</Text>
                <Text style={styles.instructions}>To get started, click below!</Text>
                <View style={styles.container}>
                    <TouchableHighlight style={styles.button} onPress={this.onPress}>
                        <Text> Sign Up Here! </Text>
                    </TouchableHighlight>
                    <View style={styles.countContainer}>
                        <Text style={styles.countText}>
                            {this.state.count !== 0 ? this.state.count : null}
                        </Text>
                    </View>
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "#F5FCFF"
    },
    welcome: {
        fontSize: 20,
        textAlign: "center",
        margin: 10
    },
    instructions: {
        textAlign: "center",
        color: "#333333",
        marginBottom: 10
    },
    button: {
        alignItems: "center",
        backgroundColor: "blue",
        width: 100,
        padding: 10
    },
    countText: {
        padding: 20,
        color: "#FF00FF"
    }
});

export default App;