Value | Color |
---|---|
\e[0;30m | Black |
\e[0;31m | Red |
\e[0;32m | Green |
\e[0;33m | Yellow |
\e[0;34m | Blue |
\e[0;35m | Purple |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fakeParseJSON(str) { | |
let i = 0; | |
const value = parseValue(); | |
expectEndOfInput(); | |
return value; | |
function parseObject() { | |
if (str[i] === "{") { | |
i++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function takeLatest(asyncFunc) { | |
let index = 0; | |
return (...argv) => { | |
function execNext(func, reqIndex) { | |
return (...argv2) => { | |
if (reqIndex === index) { | |
func.call(this, ...argv2); | |
} | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseMoney(num) { | |
return Math.floor(num * 100) / 100; | |
} | |
const gongjijin = { | |
// 个人缴纳部分 | |
person: { | |
base: 0.12, | |
add: 0 // 补充住房公积金 | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//.js文件的行数 | |
find . -name "*.js" | xargs wc -l | |
//.js .jsx .css .scss 文件内容总行数 | |
find . -name "*.js" -or -name "*.jsx" -or -name "*.css" -or -name "*.scss" |xargs grep -v "^$"|wc -l |
A tiny (265 byte) utility to create state machine components using two pure functions.
The API is a single function that accepts 2 pure functions as arguments:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Utility to only call Redux updates in RequestAnimationFrame's | |
* Also uses React-dom's batchedUpdates | |
*/ | |
import raf from 'raf'; | |
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom'; | |
let rafID; | |
let notifyFunc; | |
function animFrame() { |
IE9, IE10, and IE11 don't properly scale SVG files added with img
tags when viewBox
, width
and height
attributes are specified. View this codepen on the different browsers.
Image heights will not scale when the images are inside containers narrower than image widths. This can be resolved in 2 ways.
As per this answer on Stackoverflow, the issue can be resolved by removing just the width
and height
attributes.
方法名 | 类似 | Mounted | 是否可以调用setState | 可以做什么? |
---|---|---|---|---|
constructor | initialize() | 否 | 否 | 初始化没有副作用的方法/属性 |
componentWillMount | beforeDomReady() | 否 | 不建议 | 只有在createClass中才需要使用的构造函数 |
render | render | 否 | 禁止 | 渲染但是请不要设置任何state |
componentDidMount | domReady() | 是 | 是 | DOM已经构建好,可以调用数据初始化jQuery插件 |
componentWillReceiveProps | onChange() | 是 | 是 | 如有需要可以接收Prop来更新state |
componentWillUpdate | beforeRender() | 是 | 否 | 在组件接收到新的props或者state但还没有render时被执行 |
shouldComponentUpdate | shouldRender() | 是 | 否 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder