打赏

2024年4月9日

摘要: 1. 安装 redux-persist npm install redux-persist 2.store/index.js文件 import { configureStore,combineReducers } from "@reduxjs/toolkit"; import { persistSt 阅读全文
posted @ 2024-04-09 17:31 jlyuan 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 1.安装 craco工具 npm i -D @craco/craco craco 是一个用于扩展 Create React App(CRA)的工具,CRA 是一个用于快速搭建 React 应用的脚手架工具。CRA 提供了一个简单的项目结构和配置,使得开发者可以快速开始一个 React 项目的开发。然 阅读全文
posted @ 2024-04-09 15:37 jlyuan 阅读(20) 评论(0) 推荐(0) 编辑

2024年4月8日

摘要: 在介绍 React Router 的概念以前,需要先区分两个概念: react-router:为 React 应用提供了路由的核心功能; react-router-dom:基于 react-router,加入了在浏览器运行环境下的一些功能。 1. 安装(本文6.22.3版本) npm i react 阅读全文
posted @ 2024-04-08 23:04 jlyuan 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1. action传参,用payload属性接收 <button onClick={()=>dispatch(addNum(2))}> +2</button> 2. redux 中异步 操作,与同步类似,需要比同步多封装一个函数// 使用RTK创建store, createSlice 创建reduc 阅读全文
posted @ 2024-04-08 21:18 jlyuan 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1. 安装 npm install @reduxjs/toolkit react-redux 2.创建store目录 3. 创建counterStore.js // 使用RTK创建store, createSlice 创建reducer的切片 import {createSlice } from " 阅读全文
posted @ 2024-04-08 17:42 jlyuan 阅读(4) 评论(0) 推荐(0) 编辑

2024年3月24日

摘要: 1. 创建 ng g s service/list 2.在app.module.ts中引入 import { ListService } from './service/list.service'; @NgModule({ ... providers: [ListService], }) 3.在组件 阅读全文
posted @ 2024-03-24 14:11 jlyuan 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1. 父子组件数据传递 1.1 父传子 @Input() <app-child [message]="message"></app-child> 子组件 import { Input } from '@angular/core'; @Input() message?: string; 1.2 子传父 阅读全文
posted @ 2024-03-24 13:18 jlyuan 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 1. ngIf <div *ngIf="flag" id="11"> ngif1</div> 2. ngFor <div *ngFor="let item of books;index as i"> {{i + 1}} - {{item.name}} </div> 3. ngSwith <div [ 阅读全文
posted @ 2024-03-24 10:48 jlyuan 阅读(2) 评论(0) 推荐(0) 编辑

2024年3月1日

摘要: 在vue.config.js中配置如下 chainWebpack: (config) => { config.plugin("define").tap((args) => { args[0]["process"] = {...args[0]["process.env"]} return args; 阅读全文
posted @ 2024-03-01 17:47 jlyuan 阅读(175) 评论(0) 推荐(0) 编辑

2023年7月17日

摘要: provide/inject 可解决深层组件传值问题 父组件 import { provide } from "vue"; const curValue = ref(props.modelValue); provide('curTabName',curValue); 子组件 import { inj 阅读全文
posted @ 2023-07-17 11:50 jlyuan 阅读(12) 评论(0) 推荐(0) 编辑

导航