【问题标题】:Unexpected Token, expected { (26:2)意外令牌,预期 { (26:2)
【发布时间】:2017-04-06 17:56:44
【问题描述】:

我是新来的,我不知道这行代码有什么问题。 我尝试换行,错误只会改变主题。

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

import { Textbox } from './src/Textbox';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>Hello Hector. Open up App.js to start working on your app!</Text>
        <Text>Changes you make will automatically reload.</Text>
        <Text>Shake your phone to open the developer menu.</Text>
      </View>
    );
  }
};

export class Textbox extends Component ({
  render () {
    return (
      <View style={styles.useless}> 
        <Textbox />
      </View>
    );
  },
});  

【问题讨论】:

    标签: react-native


    【解决方案1】:

    你的第二堂课有语法错误:

    export class Textbox extends Component ({ <---shouldnt have parans
      render () {
        return (
          <View style={styles.useless}> 
            <Textbox />
          </View>
        );
      },
    });   <---shouldnt have parans
    

    改成:

     export class Textbox extends Component {
      render () {
        return (
          <View style={styles.useless}> 
            <Textbox />
          </View>
        );
      }
    };  
    

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-19
      • 2019-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多