10 2020 档案

摘要:1: let arr = [1,2,3,4,5,6] // 增强for循环 没有返回值 arr.forEach((item,index,arr) => { console.log(item); console.log(index); console.log(arr); }) 2: let arr2  阅读全文
posted @ 2020-10-20 23:11 徐的小博客 阅读(2125) 评论(0) 推荐(0) 编辑
摘要:props 可以把数据从父传给子,如果想要实现子传给父数据,可以把数据当成函数的参数传递给父组件,下面给一行代码揣摩: class ParentCom extends React.Component{ constructor(props){ super(props) this.state = { c 阅读全文
posted @ 2020-10-15 20:55 徐的小博客 阅读(1338) 评论(0) 推荐(0) 编辑
摘要:React 组件支持 函数式组件与类组件的区别和使用,函数式组件比较简单,一般用于静态没有交互事件内容的组件页面。类组件,一般称为动态组件,那么一般会有交互或者数据修改的操作。 1 函数式组件: function Childcom (props) { console.log(props); let  阅读全文
posted @ 2020-10-11 20:47 徐的小博客 阅读(102) 评论(0) 推荐(0) 编辑
摘要:React Jsx: 优点: 1: JSX语法执行更快,编译为Javascript代码时进行了优化 2: 类型更安全,编译过程如果出错就不编译 3: JSX编写模板更加简单快捷 注意: 1: JSX必须要有根节点 2: 正常的HTML元素要小写.如果大写会默认为组件 JSX表达式 1: 由Html元 阅读全文
posted @ 2020-10-11 19:17 徐的小博客 阅读(242) 评论(0) 推荐(0) 编辑