摘要: const numbers = [1, 2, 3, 4, 5]; const listItems = numbers.map((numbers) => {numbers} ); ReactDOM.render( {listItems}, document.getElementById('example') ); function ListItem(props) { // ... 阅读全文
posted @ 2018-11-14 20:05 沉默的末1993 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 传参判断 阅读全文
posted @ 2018-11-14 19:53 沉默的末1993 阅读(93) 评论(0) 推荐(0) 编辑
摘要: function ActionLink() { function handleClick(e) { e.preventDefault(); console.log('链接被点击'); } return ( 点我 ); } class Toggle extends React.Component { constructor... 阅读全文
posted @ 2018-11-14 19:49 沉默的末1993 阅读(89) 评论(0) 推荐(0) 编辑
摘要: class WebSite extends React.Component { constructor() { super(); this.state = { name: "菜鸟教程", site: "https://www.runoob.com" } } render() { return ( ... 阅读全文
posted @ 2018-11-14 17:42 沉默的末1993 阅读(90) 评论(0) 推荐(0) 编辑
摘要: function FormattedDate(props){ return ( 现在是{props.date} ) } class Clock extends React.Component{ constructor(props){ supper(props); this.state={date:new Date()}; } componentDidM... 阅读全文
posted @ 2018-11-14 17:29 沉默的末1993 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 封装一个组件 组件的样式写在组件内的html中,写在组件标签不起作用。若要为某个元素增加样式,使用className 阅读全文
posted @ 2018-11-14 16:38 沉默的末1993 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 使用JSX代替常规Javascript 使用JSX自定义属性 data-自定义属性名 独立文件 表达式写在{}中,JSX不能使用if else 可以用三元运算符 样式 数组 阅读全文
posted @ 2018-11-14 16:19 沉默的末1993 阅读(93) 评论(0) 推荐(0) 编辑
摘要: React元素创建后无法修改其内容和属性。唯一的办法是创建新的元素,传入ReactDOM.render()方法 三种实现形式: 1.整体替换 2.将要展示的部分封装起来 解析:每隔1秒执行tick 触发Clock 将参数传递到Clock函数中,修改html 3.创建React.Component的类 阅读全文
posted @ 2018-11-14 15:31 沉默的末1993 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 最基本使用: 引入依赖文件: 将Hello World插入到id为example节点中 也可以写成 想更新元素,只能是创造一个新的元素,传入ReactDOM.render()方法 阅读全文
posted @ 2018-11-14 14:47 沉默的末1993 阅读(369) 评论(0) 推荐(0) 编辑