摘要: react没有语法糖,循环和条件判断都是通过原生js来实现 1. 条件判断 // 三元表达式 const getDiv = (flag)=>{ return ( <div>XXX</div> {flag?<div>条件1</div>:<div>条件2</div>} ) } ... // if判断 c 阅读全文
posted @ 2023-03-21 17:17 抽风的皮鞭 阅读(497) 评论(0) 推荐(0)
摘要: 这是由于ant v4.20+优化了导航菜单Menu的使用方式,采用优化后的方式使用菜单组件就可以了。 更新前: <Menu onClick={this.handleClick} style={{ width: 256 }} defaultSelectedKeys={['1']} defaultOpe 阅读全文
posted @ 2023-03-16 18:07 抽风的皮鞭 阅读(1332) 评论(0) 推荐(0)
摘要: router.js import React, { Component } from 'react'; import { Routes, Route, Navigate } from 'react-router-dom'; {/* 引入组件 */} import Home from 'XXX'; i 阅读全文
posted @ 2023-03-16 17:12 抽风的皮鞭 阅读(382) 评论(0) 推荐(0)
摘要: ::-webkit-scrollbar { width: 7px; height: 7px; background-color: #0000001a; } ::-webkit-scrollbar-track { background-color: #0000001a; } ::-webkit-scr 阅读全文
posted @ 2023-03-03 09:57 抽风的皮鞭 阅读(50) 评论(0) 推荐(0)
摘要: 当前端收到后端传过来的数据流时,前端文件下载方法: let url = window.URL.createObjectURL(new Blob([res.body])); let link = document.createElement('a'); link.style.display = 'no 阅读全文
posted @ 2023-02-28 09:21 抽风的皮鞭 阅读(138) 评论(0) 推荐(0)
摘要: react中属性的命名方式都是小驼峰(如:className、onClick) 1. 数据绑定 react中的数据绑定是使用大括号{} <div className="content">{aa}</div> // 函数式组件 <div className="content">{this.state. 阅读全文
posted @ 2023-02-20 11:27 抽风的皮鞭 阅读(222) 评论(0) 推荐(0)
摘要: 目前react官网已经不建议下载create-react-app脚手架到本地的方式来搭建项目了,我们可以直接用npx的方式来快速搭建react项目。我本地用的node版本是18.xxx的,如果是低版本的node和npm的话执行命令会失败(我之前用的node版本是14.xxx的,创建项目一直失败,试了 阅读全文
posted @ 2022-12-12 16:20 抽风的皮鞭 阅读(128) 评论(0) 推荐(0)
摘要: 1. 根目录下新建proxy.conf.json文件 { "/api/*": { "target": "http://localhost:4200", "secure": false, "changeOrigin": true, "pathRewrite": { "^/api": "" // 将请求 阅读全文
posted @ 2022-12-12 15:30 抽风的皮鞭 阅读(494) 评论(0) 推荐(0)
摘要: 当我们react项目中使用a标签但是没加href属性时,会看到如下警告: The href attribute is required for an anchor to be keyboard accessible. Provide a valid,navigable address as the 阅读全文
posted @ 2022-12-09 16:49 抽风的皮鞭 阅读(672) 评论(0) 推荐(0)
摘要: 我们node项目中cache和cookie中保存中文时不能直接保存,要用base64加密来保存。当我们项目中在浏览器端通过http请求到这些加密字符串进行解密展示时会出现部分乱码,原因是接收到数据后浏览器会先对加密字符串做一层加密,会改变部分字符,造成正常解析失败,解决方法是: import { B 阅读全文
posted @ 2022-12-09 16:01 抽风的皮鞭 阅读(815) 评论(0) 推荐(0)