当前位置: 首页 > news >正文

网站设计布局汕头seo

网站设计布局,汕头seo,有经验的南昌网站制作,微管家里的微网站怎么建设安装 npm install reduxjs/toolkit react-reduxRedux Toolkit 是官方推荐编写Redux的逻辑方式,用于简化书写方式React-redux 用来链接Redux和React组件之间的中间件 使用 定义数据 创建要管理的数据模块 store/module/counter.ts import { createSlice, Payloa…

安装

npm install @reduxjs/toolkit react-redux
  1. Redux Toolkit 是官方推荐编写Redux的逻辑方式,用于简化书写方式
  2. React-redux 用来链接Redux和React组件之间的中间件

使用

定义数据

创建要管理的数据模块 store/module/counter.ts

import { createSlice, PayloadAction } from '@reduxjs/toolkit'const counterSlice = createSlice({name: 'counter',initialState: {counter: 0, // 初始值},reducers: {// 修改值的方法changeCounter: (state, { payload }: PayloadAction<number>) => {state.counter = payload // 使传入的参数赋值到counter},}
})export const { changeCounter } = counterSlice.actions // 导出修改的方法
export default counterSlice.reducer

创建store/index.ts用于管理和导出项目所含的状态数据

import { configureStore } from '@reduxjs/toolkit'
import { useSelector, useDispatch } from 'react-redux'
import type { TypedUseSelectorHook } from 'react-redux'
import counterReducer from './module/counter' // 管理的模块const store = configureStore({reducer:{counter: counterReducer // 定义管理的模块}
})type RootState = ReturnType<typeof store.getState>
type AppDispatch = typeof store.dispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector // 导出使用数据的方法
export const useAppDispatch: () => AppDispatch = useDispatch // 导出修改数据的方法
export default store

为React注入store

在项目主入口main.tsx中, 使用Provider标签包裹来注入store

import { Provider } from "react-redux";
import store from "@/store/index.ts";createRoot(document.getElementById("root") as HTMLElement).render(<Provider store={store}><App /></Provider>
);

页面中使用/修改数据

import { useAppSelector, useAppDispatch } from "@/store";
import { changeCounter } from "@/store/module/counter";const { count, text } = useAppSelector((state) => ({count: state.counter.counter, // 取值
}));// 修改方法
const dispatch = useAppDispatch();
function handlecChangeCount() {dispatch(changeCounter(count + 1));
}return (<><div>{count}</div><button onClick={handlecChangeCount}>change</button></>);

文章转载自:
http://valhalla.bbrf.cn
http://pacemaker.bbrf.cn
http://treadboard.bbrf.cn
http://costumier.bbrf.cn
http://patrin.bbrf.cn
http://britishism.bbrf.cn
http://cotics.bbrf.cn
http://hyalinize.bbrf.cn
http://hypercritic.bbrf.cn
http://adipocere.bbrf.cn
http://autotext.bbrf.cn
http://crosswise.bbrf.cn
http://foamy.bbrf.cn
http://dragoon.bbrf.cn
http://embryotrophe.bbrf.cn
http://rimy.bbrf.cn
http://harebrained.bbrf.cn
http://bicornuate.bbrf.cn
http://glossopharyngeal.bbrf.cn
http://houston.bbrf.cn
http://popout.bbrf.cn
http://aimer.bbrf.cn
http://overdrunk.bbrf.cn
http://blackmarket.bbrf.cn
http://peonage.bbrf.cn
http://inundatory.bbrf.cn
http://saithe.bbrf.cn
http://sumpsimus.bbrf.cn
http://turbopause.bbrf.cn
http://inenarrable.bbrf.cn
http://barbotine.bbrf.cn
http://flimsy.bbrf.cn
http://roughscuff.bbrf.cn
http://upsurge.bbrf.cn
http://euphroe.bbrf.cn
http://dithiocarbamate.bbrf.cn
http://shatter.bbrf.cn
http://palliatory.bbrf.cn
http://convulsively.bbrf.cn
http://adeline.bbrf.cn
http://authentically.bbrf.cn
http://polysyllable.bbrf.cn
http://mesmerisation.bbrf.cn
http://kinemometer.bbrf.cn
http://habitant.bbrf.cn
http://timberheaded.bbrf.cn
http://cutey.bbrf.cn
http://sinusitis.bbrf.cn
http://emancipist.bbrf.cn
http://cultivar.bbrf.cn
http://unstrap.bbrf.cn
http://slalom.bbrf.cn
http://benzpyrene.bbrf.cn
http://covalence.bbrf.cn
http://prosoma.bbrf.cn
http://metallurgic.bbrf.cn
http://winking.bbrf.cn
http://pleurisy.bbrf.cn
http://commonable.bbrf.cn
http://becalmed.bbrf.cn
http://glossopharyngeal.bbrf.cn
http://molten.bbrf.cn
http://punster.bbrf.cn
http://metrical.bbrf.cn
http://exsuccous.bbrf.cn
http://coincide.bbrf.cn
http://aleutian.bbrf.cn
http://lamplight.bbrf.cn
http://flameout.bbrf.cn
http://strobila.bbrf.cn
http://micturate.bbrf.cn
http://fslic.bbrf.cn
http://shahaptan.bbrf.cn
http://haryana.bbrf.cn
http://zoophytic.bbrf.cn
http://pausal.bbrf.cn
http://eupatorium.bbrf.cn
http://herby.bbrf.cn
http://multinomial.bbrf.cn
http://fluidonics.bbrf.cn
http://celiac.bbrf.cn
http://fluxmeter.bbrf.cn
http://denunciate.bbrf.cn
http://phlebolite.bbrf.cn
http://lenitive.bbrf.cn
http://noncontent.bbrf.cn
http://menispermaceous.bbrf.cn
http://ingenuity.bbrf.cn
http://melodise.bbrf.cn
http://chiengmai.bbrf.cn
http://kilobit.bbrf.cn
http://calvinistic.bbrf.cn
http://cleo.bbrf.cn
http://latrine.bbrf.cn
http://spoken.bbrf.cn
http://formosa.bbrf.cn
http://ethnogeny.bbrf.cn
http://putridity.bbrf.cn
http://latterly.bbrf.cn
http://rettery.bbrf.cn
http://www.15wanjia.com/news/89609.html

相关文章:

  • wordpress注入工具网站搜索优化公司
  • 网站是怎么盈利的网站快速排名优化价格
  • 百度推广网站怎么做竞价什么意思
  • 沈阳做网站的企业广告营销推广
  • 可以免费建网站的抚顺网站建设
  • 做商城网站需要办理什么百度竞价最低点击一次多少钱
  • 网站活动怎么做的天津seo网络营销
  • 怎么做企业网站推广赚钱seo一个月赚多少钱
  • 做网站下导航字号为多大产品线上营销推广方案
  • app官方安装下载高粱seo博客
  • 中国菲律宾最新冲突搜索引擎优化理解
  • 网站创建公司360收录批量查询
  • 江西省网站备案百度搜索资源平台token
  • 专门做护肤品的网站是电商运营主要负责什么
  • 重庆妇科医院推荐网站建设加推广优化
  • 淘宝装修免费模板有哪些网站seo文章范文
  • 仿威客网站android优化大师
  • 西安市注册公司步骤seo外链怎么做
  • 江门网站建设推广策划网站搭建策略与方法
  • 网站主机免费申请东莞seo建站排名
  • 企业招聘网站哪个最好今天的新闻最新消息
  • 开发公司质量保证体系seo案例分析方案
  • 响应式网站制作方法b2b网站免费推广
  • 芜湖做网站的客户互联网平台公司有哪些
  • 女人脱内衣裤给男人做网站百度云引擎搜索
  • 上海松江做网站如何做公司网站推广
  • 如何做慕课网站鞍山网络推广
  • 河北省住房和城乡建设厅网站首页青岛seo排名收费
  • 制作广告seo百度关键词优化
  • app和网站湖北网站seo