09 2021 档案

react数据流-随笔
摘要:redux: 1,store:提供了一个全局的store变量,用来存储我们希望从组件内部抽离出去的那些公用的状态; 2,action:提供了一个普通对象,用来记录我们每一次的状态变更,可日志打印与调试回溯,并且这是唯一的途径; 3,reducer:提供了一个纯函数,用来计算状态的变更; redux特 阅读全文

posted @ 2021-09-30 15:47 Hhhhhhhhii 阅读(38) 评论(0) 推荐(0)

React-Redux
摘要:1,store 保存数据的地方,管理全局的状态 import { createStore } from 'redux'; const store = createStore(reducter); store.getState();store.dispatch(action);store.subscr 阅读全文

posted @ 2021-09-22 20:19 Hhhhhhhhii 阅读(47) 评论(0) 推荐(0)

dva.js的dispatch的回调
摘要:在dva@2中实现回调可以将回调函数作为参数dispatch: dispatch({ type: 'model/fetch', payload: { resolve, id: userId, }, callback: res => { console.log(res); } }) 然后在model的 阅读全文

posted @ 2021-09-22 18:13 Hhhhhhhhii 阅读(549) 评论(0) 推荐(0)

React函数组件模拟生命周期(useEffect)
摘要:React Hooks提供React.useEffect来解决函数组件没有生命周期的问题 React.useEffect(fn,?)第一个参数是特定实时机执行的回调函数,第二个参数是指依赖项 1.模拟componentDidMount第一次渲染 useEffect(() => { console.l 阅读全文

posted @ 2021-09-22 12:39 Hhhhhhhhii 阅读(1547) 评论(0) 推荐(0)

React生命周期
摘要: 阅读全文

posted @ 2021-09-12 23:22 Hhhhhhhhii 阅读(31) 评论(0) 推荐(0)

React-Hooks
摘要:hooks相比较于class的优势: 1,学习成本低,不涉及生命周期。useState,useEffect 2,业务逻辑聚合。useEffect 3,闭包问题。 七大hooks: 1,useState改变状态 const [x, setx] = react.useState(x的初始值); reac 阅读全文

posted @ 2021-09-09 17:40 Hhhhhhhhii 阅读(63) 评论(0) 推荐(0)

导航