-
设置图标时候喜欢用img src={require('')} 或者设置元素的background-image 怎么都显示不出来,换张图就行,原来是切的图太大了 需要设置backgroud-size,可以设置为content/cover,即把图片扩展至父元素最够大
-
设置动态属性名,name =
${balabala}; {[name]: 'aaa'} -
使用for of 和其他遍历的区别???forEach? map?
-
Json.parse('[8]') => [8]
-
rules.splice(index, 1);
-
calc() 函数用于动态计算长度值。
- 需要注意的是,运算符前后都需要保留一个空格,例如:
width: calc(100% - 10px)
-
antd tooltip可以挂载到父元素,不指定默认挂载body上没办法用命名空间限制样式
-
z-index失效,需设置定位
-
height 100vh和100%区别是,不管有没有内容100vh始终是视口高度 若元素被fixed元素挡住,可以给被挡住元素设置margin负值
-
pubsub 未挂载的组件之间不能传递状态
递归
-
页面白屏问题,一定是render导致的,render中不能返回null
const isLastTd = index === (arr&&arr.length-1) ? true: false; 没有()一直false const index=1 const arr=[1,2,3] index===arr&&arr[0] //false index===(arr&&arr[0]) //true
-
手动移除modal元素 dom[0].parentElement.removeChild(dom[0])
-
commit错了分支
git reset --hard commitId到暂存区
git reset HEAD^ 到工作区
直接checkout行不行?或者reset带不带参区别
git commit -a相当于add吗?yes
git reset --merge回滚merge代码
-
new urlSearchParams(location.search) 缺点:使用delete时url不变
-
useEffect不支持async 可以写IIFE, 或者包装一层async函数放在useEffect 回调函数中
-
JSON.parse('false')将字符串false转换成boolean类型
-
chunk包问题,某个属性找不到, 可以点击浏览器console里面的左下角格式化js
-
webpack ^中版本可以升级~小版本+大版本
-
react-router v3路由拦截 `
this.props.router.setRouteLeaveHook(this.props.route, () => { if (this.state.changeFileCount) { return '当前编辑内容尚未提交,是否要关闭?关闭后您修改的内容将会丢失!' } }); window.onbeforeunload = () => { if (_this.state.changeFileCount) { return true; } return; } `
-
浏览器默认拦截 `
window.onbeforeunload = () => { if (_this.state.changeFileCount) { return true; } return; }
`