2016-12-07 45 views
0

我是新来的反应母语和我对Windows 7和指数使用的Atom GUI 1.12.6在android手机 部署的应用程序,这是我的代码反应母语:分析错误:意外标记<

'use strict'; 

import Exponent from 'exponent'; 
import React, {Component} from 'react'; 

import { AppRegistry, Text } from 'react-native'; 

class App extends Component{ 
    constructor(props, context) { 
     super(props, context); 
     this.state = { 
     }; 
    } 

    render(){} 
     return (
      <Text>Hello world again!</Text> 
    ); 
    } 
} 
Exponent.registerRootComponent(App); 

.eslintrc文件中包含的规则:

{ 
    "extends": "airbnb/base", 
    "plugins": [ 
     "react" 
    ], 
    "env": { 
     "node": true, 
     "jasmine": true, 
    }, 
    "rules": { 
     "indent": [1, 4], 
     "no-console": 0, 
     "no-unused-vars": [1, {"vars": "local", "args": "none"}], 
     "react/forbid-prop-types": 1, 
     "react/jsx-boolean-value": 1, 
     "react/jsx-closing-bracket-location": 1, 
     "react/jsx-curly-spacing": 1, 
     "react/jsx-indent-props": 1, 
     "react/jsx-key": 1, 
     "react/jsx-max-props-per-line": 1, 
     "react/jsx-no-duplicate-props": 1, 
     "react/jsx-no-undef": 1, 
     "react/jsx-quotes": 1, 
     "react/jsx-sort-prop-types": 1, 
     "react/jsx-sort-props": 1, 
     "react/jsx-uses-react": 1, 
     "react/jsx-uses-vars": 1, 
     "react/no-danger": 1, 
     "react/no-did-mount-set-state": 1, 
     "react/no-did-update-set-state": 1, 
     "react/no-direct-mutation-state": 1, 
     "react/no-multi-comp": 1, 
     "react/no-set-state": 1, 
     "react/no-unknown-property": 1, 
     "react/prefer-es6-class": 1, 
     "react/prop-types": 1, 
     "react/react-in-jsx-scope": 1, 
     "react/require-extension": 1, 
     "react/self-closing-comp": 1, 
     "react/sort-comp": 1, 
     "react/wrap-multilines": 1, 
     "id-length": 0, 
    }, 
    "ecmaFeatures": { 
     "jsx": true 
    }, 
} 

四处错误: Atom的编辑器上的文本控制它显示“分析错误:意外令牌<”如果你忽略了,并开始部署在Android手机上使用指数在手机它显示红色的屏幕上,出现错误:“意外令牌‘<’”

回答

3

你必须在渲染方法一个错字..

render(){} 

更改为:

render() { 
    return (
     <Text>Hello world again!</Text> 
    ); 
} 
+0

感谢现在我能够在手机中部署应用程序,但在文本控制Atom编辑器显示“解析错误:意外的令牌<”如何解决这个问题? –

+0

我对Atom并不熟悉,但是您可能会使用错误的Atom语法突出显示,无法识别react ..或者eslint配置不好.. 请参阅[react Atom plugin](https://orktes.github。 io/atom-react /)和[配置eslint在Atom中反应](http://stackoverflow.com/questions/30294870/how-to-config-eslint-for-react-on-atom-editor) – atlanteh

相关问题