ReactJS with ES6 - Map

2016年4月9日

pasted image 0

import React, { Component } from 'react'; class MapTest extends Component { render() { var newsNodes = this.props.data.map(function(news) { return ( {news.title} {news.time} ); }); return (

{newsNodes}
主題 時間
); } } export class Test extends Component { constructor(props) { super(props); this.state = {data: []}; this.loadNewsFromServer(); } loadNewsFromServer() { $.ajax({ url: 'http://211.23.17.100/itravel/index.php?view=getTravelNewsList', dataType: 'json', type: 'POST', data: {page: 1}, success: function(data) { this.setState({data: data.result}); }.bind(this) }); } render() { return (
); } }

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.