首页>demo02

Demo02 - 遍历列表 by zuojj at 29 Jun 2016

HTML

<div id="olist"></div>

JAVASCRIPT

var arr = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];

ReactDOM.render(
    <ol>
    {
        arr.map(function(text, index) {
            return <li key={index}>{text}</li>
        })
    }
    </ol>, 
    document.getElementById('olist')
);

/**
 + Warning:
 + react.js:19500 Warning: Each child in an array or iterator should have a unique "key" prop. Check the top-level render call using <ul>. See https://fb.me/react-warning-keys for more information.
 */