React Native


import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  FlatList, 
  ActivityIndicator, 
  Text, 
  View
} from 'react-native';

export default class MyApp extends Component {

  constructor(props){
    super(props);
    this.state ={ isLoading: true}
  }

  componentDidMount(){
    return fetch('https://api.douban.com/v2/movie/top250?start=1&count=2')
      .then((response) => response.json())
      .then((responseJson) => {

        this.setState({
          isLoading: false,
          dataSource: responseJson.subjects,
        }, function(){

        });

      })
      .catch((error) =>{
        console.error(error);
      });
  }

  render(){

    if(this.state.isLoading){
      return(
        
          
        
      )
    }

    return(
      
        <FlatList
          data={this.state.dataSource}
          renderItem={({item}) => {item.title}, {item.year}}
          keyExtractor={(item, index) => item.id}
        />
      
    );
  }
}

AppRegistry.registerComponent('MyApp', () => MyApp);

调试

cmd + D