react学习笔记
传统实例-todoList
新建todoList
将src下的App.js删除,新建TodoList.js,然后将index.js要导入的文件和挂载的组件一并修改。
import React from 'react';
import ReactDOM from 'react-dom';
import TodoList from './TodoList';//注意点1
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<TodoList />, document.getElementById('root'));//注意点2
serviceWorker.unregister();
完善todoList
import React,{Fragment} from 'react'
const Component = React.Component
class TodoList extends Component {
render() {
return (
<Fragment>
<div><input type="text" /> <button> 添加 </button></div>
<ul>
<li>学习react</li>
<li>学习vue</li>
</ul>
</Fragment>
);
}
}
注意:最外层包裹元素