william.chan's blog

done is better than perfect

React: 生命周期方法

React中渲染过程的概览

生命周期方法 附属于React类组件的特殊方法,其在组件生命周期的特定时间点被执行。 1 2 3 4 5 6 7 componentWillMount() componentDidMount() componentWillReceiveProps() shouldComponentUpdate() componentWillUpdate() componentDidUpdate(...

React: 前端报错 node-pre-gyp WARN Using request for node-pre-gyp https download解决方法

这是权限不够的问题,下载的时候加上 --unsafe-perm

前端报错 node-pre-gyp WARN Using request for node-pre-gyp https download解决方法 报错信息 执行 npm install 时报错 1 2 3 4 5 node-pre-gyp WARN Using request for node-pre-gyp https download node-pre-gyp WARN Pre...

Node: npm 默认源切换

npx nrm ls

使用nrm工具切换淘宝源 npx nrm use taobao 切换回官方源 npx nrm use npm https://www.jianshu.com/p/bd9ffdf6c039

React: 认识React

关于React的基本概念

React 是什么? React是一个用来构建用户界面的库,它最初是由Facebook的工程师创建的。 React提供了一套基于组件的简单、灵活的API。 组件是React的基本单元,在React应用中被广泛使用。 React在程序和浏览器DOM之间实现了一个虚拟DOM层。 虚拟DOM使用快速比对算法对DOM进行高效更新。 虚拟DOM具有优秀的性能,但最大的好处是...

React: 使用 react-router-dom 实现页面跳转

react router

HashRouter 1 2 3 4 5 6 7 8 9 10 11 import {HashRouter as Router} from 'react-router-dom'; ReactDOM.render( <Provider store={store}> <Router> <App /> </Router&...

JavaScript: false value

js中布尔值为false的6种情况和js数据类型

布尔值为false的6种情况 下面6种值转化为布尔值时为false,其他转化都为true 1 2 3 4 5 6 0 //(数字0,字符串"0"布尔值为true) NaN //(无法计算结果时出现,表示"非数值";但是typeof NaN==="number") "" //(双引号)或''(单引号) (空字符串,中间有空格时也是true) fal...

Redux 中几个常用方法

react + redux

Provider 容器组件 1 2 3 4 5 6 7 8 9 import { Provider } from 'react-redux'; // render ReactDOM.render( <Provider store={store}> <App /> </Provider>, document.getElementBy...

React: mapStateToProps

https://react-redux.js.org

mapStateToProps 1 2 3 4 5 const mapStateToProps = (state /*, ownProps*/) => { return { counter: state.counter } } 参考链接 https://react-redux.js.org/introduction/basic-tutorial

React: reducer visibilityFilter returned undefined

Error: Given action SET_VISIBILITY_FILTER, reducer visibilityFilter returned undefined.

报错信息 Error: Given action “SET_VISIBILITY_FILTER”, reducer “visibilityFilter” returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hol...

CSS: 手动清除浮动 float

clear: both

css 中的浮动现象 手动清除浮动 1 2 3 4 5 .clear:after { content: '', display: block, clear: both } 参考链接 CSS 浮动