随笔分类 -  react

摘要:查看本机node.js版本: node -v 清除node.js的cache:sudo npm cache clean -f 安装 n 工具:sudo npm install -g n 安装最新版本的node.js:sudo n stable 再次查看本机的node.js版本:node -v 更新n 阅读全文
posted @ 2022-01-25 09:42 大耳朵小虎 阅读(192) 评论(0) 推荐(0)
摘要:安装 使用 接口 https://segmentfault.com/a/1190000010090233 阅读全文
posted @ 2019-02-14 16:05 大耳朵小虎 阅读(2396) 评论(0) 推荐(0)
摘要:1. 正常运行 npm run eject 2. create-react-app 的版本在低于 2.0 的时候可以在 package.json 增加 proxy 配置, 配置成如下: 3. create-react-app 的版本高于 2.0 版本的时候在 package.json 只能配置 st 阅读全文
posted @ 2019-02-14 13:57 大耳朵小虎 阅读(700) 评论(0) 推荐(0)
摘要:(1) proxy 前端的端口在:localhost:3000后端的端口在:localhost:1234所以要在webpack中配置proxy选项 (proxy是代理的意思) (2) axios 配置好proxy后,就可以用axios跨域了 在组件中 import React,{Component} 阅读全文
posted @ 2019-01-30 14:46 大耳朵小虎 阅读(262) 评论(0) 推荐(0)
摘要:this.setState是异步的,所以在this.setState之后不能立刻得到最新的state数据关于如何获取最新的数据,有如下三种方法 1.回调函数 2.利用组件生命周期函数componentDidUpdate 3.利用setTimeout 延迟为0 当setTimeout 延迟为0时 co 阅读全文
posted @ 2018-06-29 09:52 大耳朵小虎 阅读(195) 评论(0) 推荐(0)
摘要:class Tools { static loadScript(url, callback) { let old_script = document.getElementById(url); if (old_script) { if (old_script.ready == true) { // c 阅读全文
posted @ 2018-06-14 09:54 大耳朵小虎 阅读(394) 评论(0) 推荐(0)
摘要:1.) react 中 <input className="inp3" placeholder="密码" type="password" onChange={this.changepassword.bind(this)} onFocus={this.FocusFN.bind(this)} value 阅读全文
posted @ 2018-05-24 14:59 大耳朵小虎 阅读(102) 评论(0) 推荐(0)
摘要:griddle-react react-bootstrap react-cropper core-js Material UI superagent restful-error-es6 browserify react-select-popover 标签选择 react-infinite-scrol 阅读全文
posted @ 2018-03-02 12:23 大耳朵小虎 阅读(231) 评论(0) 推荐(0)
摘要:1. 测试点击的是否是span 标签 <span onClick={this.select.bind(this)}>点击</span> select( e ){ console.log(e.target.matches(`${'span'}`)) } 注:` `位EMC5字符串模板 `${xx}($ 阅读全文
posted @ 2018-01-31 10:29 大耳朵小虎 阅读(98) 评论(0) 推荐(0)
摘要:1. 被更新时触发 componentDidUpdate(prevProps, prevState){ const typrval = this.props.typrval; if (typrval prevProps.typrval) { return } (需要执行的函数) }2. 基本顺序 c 阅读全文
posted @ 2018-01-16 18:35 大耳朵小虎 阅读(106) 评论(0) 推荐(0)
摘要:1. 父组件如何获取子组件的方法以及属性? 1.)父组件: render( ){ console.log( this.refs.getmethod ); return ( <div> <children ref="getmethod" /> </div> ) } 2.)子组件: 属性 方法 阅读全文
posted @ 2018-01-16 15:12 大耳朵小虎 阅读(103) 评论(0) 推荐(0)
摘要:1.JS跳转路由(需要拿到父组件的history) clickHandle(){ let history = this.props.history; history.push( '/home') } 2.刷新页面(需要拿到父组件的history) clickHandle(){ let history 阅读全文
posted @ 2018-01-11 14:39 大耳朵小虎 阅读(644) 评论(0) 推荐(0)
摘要:1. 在项目中安装 npm install react-intl --save 2.兼容Safari各个版本需要安装intl npm install intl --save 3.编写语言包 1.)新建 en_US.js const = en_US = { hello: "Hello world !" 阅读全文
posted @ 2018-01-11 14:28 大耳朵小虎 阅读(278) 评论(0) 推荐(0)
摘要:PC: antd(蚂蚁金服)https://ant.design/index-cn 移动: mobile-antd(蚂蚁金服)https://mobile.ant.design 1. react-lazyimg-component (关于img动画效果,摘自:http://react-china.o 阅读全文
posted @ 2018-01-11 14:10 大耳朵小虎 阅读(114) 评论(0) 推荐(0)
摘要:1.函数 preventBackgroundScroll(e: React.WheelEvent<HTMLDivElement>){ const target = e.currentTarget if ((e.deltaY < 0 && target.scrollTop <= 0) ||(e.del 阅读全文
posted @ 2018-01-11 14:05 大耳朵小虎 阅读(149) 评论(1) 推荐(0)