
react
superYe7
这个作者很懒,什么都没留下…
展开
-
2020-react常见面试题
以下是我个人遇到的面试题,先列题目,答案慢慢更新~1.react生命周期。2.hooks和class的区别,为什么要用hooks?(hooks解决了哪些问题)3.react-router的实现原理?有哪几种类型,分别有什么区别?4.hashrouter是怎么实现路由跳转的?如果我直接改变URL跳转到另一个页面,描述一下过程。5.解决地狱回调的方法。6.介绍下promise。7.promiseAll其中一个方法失败后,整个结果是失败还是成功?答:失败8.介绍一下redux。原创 2020-08-27 17:24:55 · 3325 阅读 · 0 评论 -
将嵌套递归成一维数组,数组扁平化
// 原数组var a = [1, 2, [3, 4, [5, [6]]]]// 期望得到 => [1, 2, 3, 4, 5, 6]方法一:reduce()a.reduce((total, currentValue) => Array.isArray(currentValue) : total.concat(currentValue) ...原创 2020-03-12 18:33:32 · 1021 阅读 · 0 评论 -
TypeError: Cannot read property 'scrollTo' of null
在使用react中的’IScroll‘方法时可能会出现“TypeError: Cannot read property 'scrollTo' of null”报错,原因是DOM树还未建立完成或者被卸载了,这时只需要在使用’IScroll‘方法时加一个判断:this.myScroll && this.myScroll.scrollTo(0, 50, 1000, IScroll....原创 2019-04-16 10:53:59 · 3666 阅读 · 1 评论 -
删除node_modules文件
rm -rf node_modules在VS Code中直接输这个命令报错“rm不是内部命令”,换个方法即可:cnpm install rimraf -grimraf ./node_modules第一次在使用rimraf命令删除node_modules时报错了,因为目录有误,少了./,加上之后正常删除。ps:如果装了git和node的,可以直接在有node_module...原创 2019-05-22 15:32:39 · 3159 阅读 · 0 评论 -
react+antd:全局设置form表单不可编辑
在做编辑页面的时候遇到一个需求是“在指定状态下内容不可编辑”方案一:给每个<Input>、<Select>...添加disable属性这种方案在form表单内容比较多的情况下可能不是很方便,所以辜老师帮我想了方案二方案二:封装个组件全局设置disable,如下封装一个高阶组件( ./Input )import React, { useContext, ...原创 2019-08-29 20:07:56 · 17265 阅读 · 4 评论 -
一个FormItem中校验多个input
实现以下效果:将三个input封装成一个组件InputComp.js:import React, { Component } from 'react'import { Input } from 'antd'export default class InputComp extends Component { static getDerivedStateFromProps(n...原创 2019-10-10 16:14:41 · 5345 阅读 · 0 评论