美文网首页
2018-05-31

2018-05-31

作者: superKelly | 来源:发表于2018-05-31 10:36 被阅读12次

=> : 箭头函数,发布与ES6

 x => x*x  相当于  f(x) {return x*x;}

promise.then() ,前一个then的返回,作为当前then的第一个参数,递进式调用

fetch('https://facebook.github.io/react-native/movies.json')
      .then((response) => response.json())
      .then((responseJson) => {
        return responseJson.movies;
      })
      .catch((error) => {
        console.error(error);
      });

alert要写在动作函数里,写在布局里面,会报错

//错误写法
render() {
    return (
      Alert.alert('hello');  //报错
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
      </View>
    );
//正确写法
OnAlive = () => {
        Alert.alert(JSON.stringify(Platform));
    }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Button
           onPress={this.OnAlive}
           title="alive"
           accessibilityLabel="See an informative alert"
        />
      </View>
    );

相关文章

网友评论

      本文标题:2018-05-31

      本文链接:https://www.haomeiwen.com/subject/wftqsftx.html