2020年7月4日
摘要: 1.react或者vue 数据驱动视图 状态:数据结构设计 视图:组件结构设计 2.react设计todlist state数据结构设计 用数据描述所有内容 数据要结构化,易于程序操作(遍历,查找) 数据要可扩展,以便增加新功能 3.组件设计 从功能上拆分层次 尽量让组件原子化 容器组件(只管数据) 阅读全文
posted @ 2020-07-04 21:33 猪mother 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 1. DOM操作非常耗费性能 以前用jquery,可以自行控制DOM操作的时机,手动调整 Vue和React是数据驱动视图,如何有效控制DOM操作? 2. 有了一定复杂度,想减少计算次数比较难 能不能把计算,更多的转移为js计算?因为js执行速度很快。DOM变化的对比放在js层来做,真实操作DOM是 阅读全文
posted @ 2020-07-04 19:53 猪mother 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 一、使用setState现象 1.不可变值 class StateDemo extends React.Component { constructor(props) { super(props) this.state = { count: 0 } } render() { return <div> 阅读全文
posted @ 2020-07-04 19:42 猪mother 阅读(1269) 评论(1) 推荐(1) 编辑
摘要: 1.react父子组件之间通过props传递数据,通过callback回调子组件向父组件通信, 我们看下面的伪代码: class TodoListDemo extends React.Component { constructor(props) { super(props) // 状态(数据)提升 阅读全文
posted @ 2020-07-04 19:21 猪mother 阅读(205) 评论(0) 推荐(0) 编辑
摘要: class EventDemo extends React.Component { constructor(props) { super(props) this.state = { name: 'zhangsan', } // 修改方法的 this 指向 this.clickHandler1 = t 阅读全文
posted @ 2020-07-04 18:56 猪mother 阅读(612) 评论(0) 推荐(0) 编辑
摘要: 1.JSX的使用 class JSXBaseDemo extends React.Component { constructor(props) { super(props) this.state = { name: 'xiaoming', imgUrl: 'https://img1.mukewang 阅读全文
posted @ 2020-07-04 18:44 猪mother 阅读(196) 评论(0) 推荐(0) 编辑