2021年9月22日

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 阅读(24) 评论(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 阅读(497) 评论(0) 推荐(0) 编辑

React函数组件模拟生命周期(useEffect)

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

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

导航