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
const {observable, computed} = mobx; | |
const {observer} = mobxReact; | |
const {Component} = React; | |
class Message { | |
@observable title; | |
@observable likes = []; | |
@observable author = {}; | |
} |
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
{ | |
min-width:50%; | |
width: calc((25em - 100%) * 1000); // 当font-size:16px 25*16=400, 100% 大于 400时,min-width起作用,当100%小于400, max-width | |
max-width: 100%; | |
} | |
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
$BASE_FONT_SIZE = 15px | |
$MIN_WIDTH = 320px | |
$MAX_WIDTH = 540px | |
px2rem($px) | |
($px / $BASE_FONT_SIZE)rem | |
html | |
// 在元素的before伪类上写上当前真实的font-size的大小,以便JS获取 |
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
const log = (store) => (next) => (action) => { | |
console.log('start') | |
next(action) | |
console.log('end') | |
} | |
function applayMiddleware (...middlewares) { | |
return (createStore) => (reducer, preloadedState,enhancer) => { | |
const store = new createStore(reducer, preloadedState, enhancer) |
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
sinon spies, stubs(stəb,存根), mocks | |
spies sinon.spy() //会调用原来的function | |
stubs //完全代替之前的function,不会执行原来的function | |
mocks //和stubs一样,可以用来替换整个对象以改变其行为 | |
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
var obj = {a: 1, b:2} | |
console.log(JSON.stringify(obj)) // {"a":1,"b":1} | |
var obj1 = { | |
a:1, | |
b: function() { | |
console.log(1) | |
}, | |
c: undefined | |
} |
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
.listing-item__title | |
.listing-item__item--active | |
// - 两个单词的链接 | |
//__ element | |
// -- midifier |
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
Element | |
document | |
window | |
XMLHttpRequest | |
... | |
onchange={(e:FormEvent<HTMLInputElement>) => { | |
event.currentTarget | |
const v = e.target.value // property 'value' does not exit on type 'EventTarget' |
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
var foo = {} | |
Object.defineProperty(foo, 'name', { | |
configurable: true, //是否可以delete foo.delete | |
enumerable: true, // 是否for in可以返回属性 | |
writable:true, //是否可以重新赋值 | |
value: 'kobe' | |
}) | |
var descriptor = Object.getOwnPropertyDescriptor(foo, 'name') | |
console.log(descriptor.value) |
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 fnWrapDecorator(fn) { | |
return (...args) => { | |
return (target, propertyKey, descriptor) => { | |
const fn = descriptor.value | |
let wrappedFn = fn.applay(null, [fn, ...args]) | |
return { | |
configurable: true, | |
get() { | |
return fn |
OlderNewer