随笔分类 -  react

摘要:记录学习的文章,参考 回顾 在介绍一下这两个hooks的作用之前,我们先来回顾一下react中的性能优化。在hooks诞生之前,如果组件包含内部state,我们都是基于class的形式来创建组件。当时我们也知道,react中,性能的优化点在于: 1、调用setState,就会触发组件的重新渲染,无论 阅读全文
posted @ 2021-08-12 15:31 王希有 阅读(794) 评论(0) 推荐(1)
摘要:接上文: https://www.cnblogs.com/-roc/p/15102866.html 续 1、安装 cnpm install @better-scroll/core --save cnpm install @better-scroll/pull-up --save cnpm insta 阅读全文
posted @ 2021-08-11 16:59 王希有 阅读(814) 评论(0) 推荐(0)
摘要:git https://gitee.com/mirrors/better-scroll/ 1.x 文档 https://better-scroll.github.io/docs-v1/doc/zh-hans/ 2.x文档 https://better-scroll.github.io/docs/zh 阅读全文
posted @ 2021-08-05 13:24 王希有 阅读(344) 评论(0) 推荐(0)
摘要:如果你使用create-react-app创建项目,执行命令 yarn build 后,直接以静态方式打开build文件夹内的index.html,会看到页面显示出现问题,打开console后会看到js、css、svg等文件的路径出现问题。 解释: 在打包之前,在 package.json 中 pr 阅读全文
posted @ 2021-08-04 14:07 王希有 阅读(4091) 评论(0) 推荐(0)
摘要:1、 npm i redux-persist --save 2、store/index import { createStore, combineReducers } from 'redux'; import reducers from './reducers/index'; import {per 阅读全文
posted @ 2021-08-02 11:24 王希有 阅读(339) 评论(0) 推荐(0)
摘要:在做全局loading时,出现的问题,使用 antd-mobile 中 Icon 组件,导致 loading组件无法关闭的问题, loading.jsx import React from 'react'; import ReactDOM from 'react-dom'; import { Ico 阅读全文
posted @ 2021-07-28 14:39 王希有 阅读(1280) 评论(0) 推荐(0)
摘要:弄了好长时间,记得之前写的时候没问题呀,现在不知道哪里出现问题,后来才发现 是 exact 和 跳转子路由 路径的问题,哎 App.js import React, {lazy, Suspense} from "react"; import { Switch, Route } from 'react 阅读全文
posted @ 2021-07-27 16:39 王希有 阅读(2843) 评论(0) 推荐(0)
摘要:1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <meta charset="utf-8"> 6 <title></title> 7 </head> 8 9 <body> 10 <h1></h1> 11 </body> 12 13 </html> 14 <script 阅读全文
posted @ 2021-07-07 09:50 王希有 阅读(1670) 评论(0) 推荐(0)
摘要:原创 <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta charset="utf-8"> <meta content="width=devic 阅读全文
posted @ 2021-07-07 09:38 王希有 阅读(741) 评论(1) 推荐(0)
摘要:React.forwardRef 会创建一个React组件,这个组件能够将其接受的 ref 属性转发到其组件树下的另一个组件中。这种技术并不常见,但在以下两种场景中特别有用: 官方解释: https://react.docschina.org/docs/forwarding-refs.html#fo 阅读全文
posted @ 2021-06-24 13:49 王希有 阅读(2850) 评论(0) 推荐(0)
摘要:官方: https://react.docschina.org/docs/react-api.html#reactcomponent 其他博主: React.Children提供了处理this.props.children的工具,this.props.children可以任何数据(组件、字符串、函数 阅读全文
posted @ 2021-06-23 14:29 王希有 阅读(1140) 评论(0) 推荐(0)
摘要:React 16.6.0 正式发布了!这次主要更新了两个新的重要功能: React.memo() React.lazy(): 使用 React Suspense 进行代码拆分和懒加载 React.memo() 是什么? React.memo() 和 PureComponent 很相似,它帮助我们控制 阅读全文
posted @ 2021-06-22 16:20 王希有 阅读(291) 评论(0) 推荐(0)
摘要:提到PureComponent,应该并不是react与生俱来就有的,而应该是在15.3版本之后才出现的,主要是为了取代之前的PureRenderMixin。所以对于几年不怎么接触react的我来说,当提到PureComponent的时候,还是有那么些许的懵逼。更不要说它于Component的区别是什 阅读全文
posted @ 2021-06-22 15:03 王希有 阅读(563) 评论(0) 推荐(0)
摘要:官网地址 https://react.docschina.org/docs/thinking-in-react.html 官网介绍了react开发的哲学,即思维模式,有助于理解和实际开发项目。值得推荐! class ProductCategoryRow extends React.Component 阅读全文
posted @ 2021-06-22 13:58 王希有 阅读(200) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document< 阅读全文
posted @ 2021-06-16 15:04 王希有 阅读(720) 评论(0) 推荐(0)
摘要:// 原生js 手机端 调用 拍照、录像、录音、相册(含图片或视频)、音频文件等 import React, {useEffect} from 'react' function Camera() { useEffect(() => { // 图片选取并回显 document.querySelecto 阅读全文
posted @ 2021-03-29 14:13 王希有 阅读(1901) 评论(0) 推荐(0)
摘要:优化点 1、当顶部有其他元素或组件时,画板笔画起笔不在落笔位置,如添加backHome组件 2、更改清除画图时,起笔长度变长问题 BackHome.js import React, {useImperativeHandle} from 'react' import { useHistory } fr 阅读全文
posted @ 2021-03-22 16:17 王希有 阅读(279) 评论(0) 推荐(0)
摘要:import React, { Component } from 'react' import { Button, Divider, Row, Col } from 'antd' class Autograph extends Component { state = { base: '' // ba 阅读全文
posted @ 2021-03-19 15:36 王希有 阅读(511) 评论(0) 推荐(0)
摘要:文件目录 -home --api --page --route -blog --api --page --route -poetry --api --page --route -photos --api --page --route -index.js 其中,route/index 做类似如下配置, 阅读全文
posted @ 2021-03-16 16:58 王希有 阅读(360) 评论(0) 推荐(0)
摘要:常用总结 一、基本的 1、BrowserRouter 表示一个路由的跟容器,将来所有跟路由相关的东西,都要包裹在其中 2、HashRouter 表示一个路由的跟容器,将来所有跟路由相关的东西,都要包裹在其中 3、Route 具有两种身份: 1.它是一个路由匹配规则; 2.它是一个占位符,表示将来匹配 阅读全文
posted @ 2021-03-12 10:53 王希有 阅读(6882) 评论(0) 推荐(1)