01 2022 档案

摘要:@reduxjs/toolkit 场景:获取产品详情 @reduxjs/toolkit 依赖了redux、redux-thunk,所以使用toolkit就不需要额外下载redux,意味着可以再多个框架使用,但是并没有react-redux,所以仍然需要安装react-redux。依赖了redux-t 阅读全文
posted @ 2022-01-20 18:12 shine_lovely 阅读(1306) 评论(0) 推荐(0) 编辑
摘要:场景:切换语言、请求产品列表 src/index.tsx import React from 'react' import ReactDOM from 'react-dom' import { Provider } from 'react-redux' // react-redux 利用上下文con 阅读全文
posted @ 2022-01-14 12:42 shine_lovely 阅读(63) 评论(0) 推荐(0) 编辑
摘要:场景:切换语言、请求产品列表 src/index.tsx import React from 'react' import ReactDOM from 'react-dom' import { Provider } from 'react-redux' // react-redux 利用上下文con 阅读全文
posted @ 2022-01-13 21:56 shine_lovely 阅读(102) 评论(0) 推荐(0) 编辑
摘要:场景:切换语言 使用react-redux的步骤 安装 react-redux依赖 在src/index.tsx中引入 react-redux中的Provider, store, 使用Provider,并加载store数据仓库 react-redux使用react的context上下文,提供一个Pr 阅读全文
posted @ 2022-01-12 17:49 shine_lovely 阅读(421) 评论(0) 推荐(1) 编辑
摘要:场景:切换语言 使用react-redux的步骤 安装 react-redux依赖 在src/index.tsx中引入 react-redux中的Provider, store, 使用Provider,并加载store数据仓库 react-redux使用react的context上下文,提供一个Pr 阅读全文
posted @ 2022-01-12 14:20 shine_lovely 阅读(987) 评论(0) 推荐(0) 编辑
摘要:场景:切换语言 安装redux依赖包 npm i redux --save 新建目录 新建目录:src/redux、src/redux/language 新建文件:src/redux/store.ts、src/redux/language/actionCreators.ts,src/redux/la 阅读全文
posted @ 2022-01-11 13:58 shine_lovely 阅读(108) 评论(0) 推荐(0) 编辑
摘要:redux redux使用步骤 使用步骤: 定义一个 reducer 函数 (根据当前想要做的修改返回一个新的状态) 使用createStore方法传入 reducer函数 生成一个store实例对象 使用store实例的 subscribe方法 订阅数据的变化(数据一旦变化,可以得到通知) 使用s 阅读全文
posted @ 2022-01-11 13:57 shine_lovely 阅读(43) 评论(0) 推荐(0) 编辑
摘要:安装 nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash 输入nvm提示报错:command not found: nvm 可能原因是本机的环境变量没有设置 打开本机的 .bash_p 阅读全文
posted @ 2022-01-10 18:36 shine_lovely 阅读(137) 评论(0) 推荐(0) 编辑
摘要:Mock API: Mock Service Worker Service Worker MSW 依赖于 Service Worker,Service Worker 本质上是浏览器在后台运行的脚本,它是完全独立于它正在处理或服务的网页。它们充当了 web 应用程序、浏览器和网络之间的代理服务器,目的 阅读全文
posted @ 2022-01-08 21:16 shine_lovely 阅读(1036) 评论(0) 推荐(1) 编辑
摘要:react项目使用i18n进行国际化封装 安装 npm i i18next react-i18next --save 配置i18n: 在根目录新建一个目录i18n 在i18n目录添加en.json、zh.json { "footer": { "detail" : "版权所有 @ React 旅游网" 阅读全文
posted @ 2022-01-08 16:38 shine_lovely 阅读(724) 评论(0) 推荐(0) 编辑
摘要:打开命令行 option + f12 + fn 快速复制上一行 cmd + D 移动当前行 option + shift + up option + shift + down 格式化 cmd + option + L 清除缩进变成单行 ctrl + shift + J 折叠/展开代码块 cmd + 阅读全文
posted @ 2022-01-07 21:44 shine_lovely 阅读(62) 评论(0) 推荐(0) 编辑
摘要:#typescript 学习笔记 申明全局类型,不用import导入,可以直接使用 项目更目录下创建typings目录 在typings中添加 index.d.ts, 在其中定义需要的类型 interface MyType { foo: string, bar: string[] } 修改 tsco 阅读全文
posted @ 2022-01-07 17:52 shine_lovely 阅读(126) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示