React-Native是否支持ES6?


貌似只支持部分ES6写法?

下面这两种写法都支持


 var EmbedModal = React.createClass({
  componentWillMount: function() { … },
});

class EmbedModal extends React.Component {
  constructor(props) {
    super(props);
    // Operations usually carried out in componentWillMount go here
  }
}

但是下面的就只支持第一种import会报错


 // ok
var React = require('react-native');
// 报错
import React from 'react-native';

而在Redux2种有都可以使用,这是什么情况呢?

reactjs react-native es6

只是来看问题 8 years, 9 months ago

RN内部有babel,是可以支持的

葬樱沁雪叹伶仃 answered 8 years, 9 months ago

https://facebook.github.io/react-native/docs/javascript-environment.html#content
官方文档里面写的很清楚,对照着看一下,哪些是支持的。

jkjkjk answered 8 years, 9 months ago

Your Answer