06 2020 档案
摘要:阻止React router跳转: 1、React不像Vue那样有router.beforeEach这样的路由钩子,但是它提供了一个组件:Prompt import { Prompt } from 'react-router-dom'; <Prompt when={true} message={lo
阅读全文
摘要:tag: # 先删除本地tag git tag -d xxx # 推送到远程 git push origin :refs/tags/xxx branch: git push origin -d xxx 这个方法同样适用于远程tag的删除
阅读全文
摘要:在React组件中有个概念叫“受控组件”,简单来说,就是状态完全给父组件来管理, 只负责显示。 <input value={value} onChange={onChange} /> 而“非受控组件“,就是状态组件自己管理,父组件只能通过ref来获取它的状态 <input ref={ref => t
阅读全文
摘要:以前理所当然的认为,只要ref作为props传进去,就可以直接给某个子组件用了,但是实际上不是这样的 const Test = ({ref}) => { return <div ref={ref}> <p>hahahha</p> </div> } class TestWarper extends R
阅读全文
摘要:普通函数 function foo<T>(x: T): T { return x; } 箭头函数 const foo = <T,>(x: T): T => x; const foo: <T>(x: T) => T = x => x;
阅读全文
摘要:阮一峰老师的文章:http://www.ruanyifeng.com/blog/2016/01/flux.html 1、Flux相对于MVC,有什么优势呢? 就是它比较简单,最大的特点是“单向数据流”(Action -> Store -> View -> Action -> Store -> ...
阅读全文
摘要:如果我们有个很奇怪的需求,需要安装同一个包的2个版本,我们可以用npm alias来实现 npm i <alias>@npm:<packageName>@版本 # 例子 npm i antd3@npm:antd@3 npm i antd4@npm:antd@4
阅读全文
摘要:我们可以看看我们的~目录,如果有.zshrc或者.bashrc,我们可以直接修改这个文件。 这个文件是用来保存个人的一些配置,例如alias、全局变量 举个例子: alias gl="git pull" alias gt="git push" alias gmm="git pull origin m
阅读全文