我正在用React.js开发一个使用IO.js的快递应用程序。我用一个JSX组件创建了一个HelloWorld类,它将返回。
'use strict'
const React=require('react');
class HelloWorld extends React.component{
render(){
return <h1>Hello,{this.props.name}</h1>
}
}
module.exports=HelloWorld当我在IO.js上编译它时,请犯以下错误:
return <h1>Hello,{this.props.name}</h1>
^
SyntaxError: Unexpected token <
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/raulgf92/Proyectos/helloWorldReact/index.js:4:18)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)明显的问题是编译JSX。IO.js,有IO.js任何编译标志,要在这个程序上使用IO.js吗?还是我要用以前的巴贝尔编译?
发布于 2017-03-26 14:39:36
使用babel可以解决这个问题,但是一个用于JSX的IO.js标志将是更有效的解决方案。关于babel的translare:
https://stackoverflow.com/questions/43029689
复制相似问题