- 博客(29)
- 收藏
- 关注
转载 Tween常用方法
参数说明: t 当前步数 b 开始位置 c 改变值大小 d 结束步数 var Tween = { Linear: function(t,b,c,d){ return c*t/d + b; }, Quad: { easeIn: functio...
2019-02-19 11:11:00
354
转载 装饰者模式
class 饮料 { constructor() { this.描述 = "未知饮料"; } getDescription() { return this.描述; } cost() { // 由子类具体实现 }}class 配料 exten...
2019-01-18 12:52:00
186
转载 观察者模式
class Subject { constructor() { this.items = []; } registerObserver(observer) { this.items.push(observer); } notifyObservers() {...
2019-01-18 10:47:00
155
转载 React-Router 在和 Redux 搭配使用时会有不按预期更新的情况
去年踩的坑,今天又碰到了。记录一下官方的说明。点我查看具体说明 转载于:https://my.oschina.net/u/3117745/blog/2980417...
2018-12-06 16:09:00
110
转载 在使用装饰器语法connect组件时,prop-types报错
今天美滋滋的搭了一个项目脚手架,顺手把 babel、webpack 什么的都升级到最新的版本。然后加入 redux,结果在和以前一样写代码时@connect( state => ({ ...state }), dispatch => ({ dispatch, action...
2018-12-06 16:08:00
210
转载 关于使用 babel@7.x 的一点疑问
今天同事在打包项目代码时发现报错了,我跟踪了一下发现是之前踩过的坑,uglifyJS 在进行代码压缩时代码必须是 ES5,不能包含 ES6 的语法。所以我在写一个包时,最后都会用 babel 转一份 ES5 的代码,然后在上传到 npm,然而现在越来越多的第三方包的作者不这么去做了,有的人说自...
2018-12-06 16:05:00
151
转载 JavaScript 继承的一些点
在 JavaScript 中,我们创建一个对象通常使用字面量的形式来创建,例如:const obj = { name: 'kaijun', age: 23, gender: 'male'}当然,我们也可以用创建 Object 对象实例的方法来写:const obj = n...
2018-12-06 15:59:00
104
转载 JavaScript Environment Requirements
React 16 depends on the collection typesMapandSet. If you support older browsers and devices which may not yet provide these natively (e.g. IE &...
2018-12-06 15:53:00
162
转载 Bugfix for getDerivedStateFromProps
今天写代码时碰到一个让我疑惑的事情,就是 React 的 getDerivedStateFromProps 在我使用 setState 更新组件时竟然也会触发。吓得我以为是 React 的 bug,赶紧上网搜一下,结果好家伙。原来我一直理解错了这个生命周期函数。我还以为只有组件的父组件更新,触...
2018-12-06 15:49:00
188
转载 @babel/polyfill 的使用及效果
众所周知某些浏览器对ES6+的支持程度堪忧,然而迫于产品的压力我们不得不去像其妥协。所以前端的代码中不可避免的会有一些polyfill代码,polyfill的直译是填充材料。我们正是靠polyfill来实现在旧的浏览器上支持一些新的ES6+的JS特性,例如(Promise、async\awai...
2018-10-31 10:28:00
1641
转载 聊聊 React17.0 将要取消的组件三个生命周期函数
Remove componentWillMount, componentWillReceiveProps, and componentWillUpdate . (Only the new “UNSAFE_” lifecycle names will work from this point ...
2018-06-08 15:20:00
681
转载 mini redux 实现
function createStore(reducer, initialState) { let currentReducer = reducer; let currentState = initialState; let listener = () => { ...
2018-03-31 17:12:00
138
转载 Object.defineProperty
参考文章ES7 装饰器介绍 转载于:https://my.oschina.net/u/3117745/blog/1550635
2017-10-14 13:45:00
95
转载 React 的方方面面(未完待续……)
概述React.Component 是一个抽象类,所以你很难直接用它,都是写一个子类去继承它,并在子类中定义一个 render() 渲染方法。class Greeting extends React.Component { render() { return <...
2017-08-27 13:10:00
112
转载 正确操作 React 中的 state
由于在 react 中,state 更新是一个异步操作的行为,所以不要依赖于 this.props 和 this.state 去计算下一个 state 的值;举个例子:// Wrongthis.setState({ counter: this.state.counter + th...
2017-08-27 12:36:00
127
转载 Mac OS 中通过终端使用 code 命令打开 VS Code
编辑 ~/.bash_profile 文件code () { if [[ $# = 0 ]] then open -a "Visual Studio Code" else [[ $1 = /* ]] && F="$1" ...
2017-08-19 14:59:00
254
转载 JavaScript 判断鼠标是否滚动到页面底部
// container 为有滚动条的容器let clientHeight = container.clientHeight; //可视区域高度let scrollTop = container.scrollTop; //滚动条滚动高度let scrollHeight = conta...
2017-08-16 15:52:00
1077
转载 macOS 安装 mysql 服务
从 mysql 官网下载 mysql 安装完成后,终端输入 mysql 命令时会提示找不到该命令。此时需要执行下面两条命令。alias mysql=/usr/local/mysql/bin/mysqlalias mysqladmin=/usr/local/mysql/bin/mysqlad...
2017-08-06 17:39:00
131
转载 macOS 显示点开头的文件
defaults write com.apple.Finder AppleShowAllFiles YES killall Finder 转载于:https://my.oschi...
2017-07-28 10:22:00
358
转载 npm 自身的升级
npm install npm@latest -g官方文档说明 转载于:https://my.oschina.net/u/3117745/blog/1475412...
2017-07-19 15:09:00
81
转载 原生 JS 设置元素的滚动条位置
element.scrollTop = 0; // 设置 element 的滚动条位置居首element.scrollTop = element.scrollHeight; // 设置 element 的滚动条位置始终居底 ...
2017-07-15 00:44:00
1114
转载 macOS 下 npm 全局安装仍然提示 Cannot find module 'xxx' 的解决方案
是因为 macOS 环境下的环境变量没有配置的原因;将全局 node_modules 目录添加到 bash_profile 中vi ~/.bash_profile.bash_profile 内容export NODE_PATH=/usr/local/lib/node_modules...
2017-07-13 14:02:00
1250
转载 pip 阿里源
[global]index-url = http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com ...
2017-06-30 14:46:00
133
转载 使用 express-http-proxy 代理本地请求
var proxy = require('express-http-proxy');var app = require('express')();app.use(function(req, res, next) { res.header("Access-Control-Allow-O...
2017-06-28 17:32:00
530
转载 react-router 中保持页面状态
最近工作中用 react + react-router 实现了一个类似今日头条的 demo。然后今天一个同事过来告诉我,能不能点击列表页进入详情页后,然后点击返回能够保持住之前列表页的状态。现在是返回后列表页又会重新加载。如果之前加载了很多页数据的话,现在又得重新加载了。易用性很差。下面附上我...
2017-06-13 14:00:00
1610
转载 原生 JS 判断页面是否滚动到底部
class Scroll { // 滚动条在Y轴上的滚动距离 static getScrollTop() { var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0; if (do...
2017-06-05 10:49:00
680
转载 Windows 上如何升级 npm
以管理员身份打开 PowerShell 执行以下命令 Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Forcenpm install -g npm-windows-upgradenpm-windows-upgrade ...
2017-05-26 10:23:00
113
转载 timestamp 转时间
timestamp => new Date(parseInt(timestamp)).toLocaleString().replace(/:\d{1,2}$/,' ') 转载于...
2017-05-04 15:08:00
149
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅