会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
panchunxin
博客园
首页
新随笔
联系
订阅
管理
2020年12月13日
react中pureComponent和Component区别
摘要: 当使用component时,父组件的state或prop更新时,无论子组件的state、prop是否更新,都会触发子组件的更新,这会形成很多没必要的render,浪费很多性能;pureComponent的优点在于:pureComponent在shouldComponentUpdate只进行浅层的比较
阅读全文
posted @ 2020-12-13 16:14 panchunxin
阅读(593)
评论(0)
推荐(0)
2020年7月15日
react 父组件如何调用子组件的方法
摘要: 父组件 bindRef (ref) { this.child = ref } clickMethod = () => { this.child.childMethod() } render () { return ( <div className='wrapper'> <p onClick={thi
阅读全文
posted @ 2020-07-15 00:24 panchunxin
阅读(4900)
评论(0)
推荐(0)
2020年6月3日
react setState是同步还是异步
摘要: changeDate = () => { const { count } = this.state this.setState({ count: count+1 }) console.log(this.state.count) } render () { const { count } = this
阅读全文
posted @ 2020-06-03 00:15 panchunxin
阅读(464)
评论(0)
推荐(0)
2020年3月22日
禁止蒙层底部页面滚动
摘要: let bodyEl = document.body let top = 0 function stopBodyScroll (isFixed) { if (isFixed) { top = window.scrollY bodyEl.style.position = 'fixed' bodyEl.
阅读全文
posted @ 2020-03-22 17:38 panchunxin
阅读(285)
评论(0)
推荐(0)
移动端开发,ios机型点击input,页面放大解决方案
摘要: 方案一: <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/> 方案二: document.doc
阅读全文
posted @ 2020-03-22 17:14 panchunxin
阅读(498)
评论(0)
推荐(0)
2020年2月26日
子组件如何改变父组件的state
摘要: 子组件调用父组件的方法,从而改变父组件中state中的值 //父组件 change (value) { console.log(value) this.setState({ red: value.red }) console.log(this.state) } render () { return
阅读全文
posted @ 2020-02-26 23:26 panchunxin
阅读(869)
评论(0)
推荐(0)
react添加多个className
摘要: <div className={`title ${index == this.state.index ? 'active' : ''}`}></div> title为固定样式,active为条件渲染
阅读全文
posted @ 2020-02-26 22:51 panchunxin
阅读(1236)
评论(0)
推荐(0)
2020年2月23日
react refs
摘要: react获取dom元素 componentDidMount () { console.log(this.refs.father) } render () { return ( <div> <div ref="father"></div> </div> ) } componentDidMount (
阅读全文
posted @ 2020-02-23 21:35 panchunxin
阅读(100)
评论(0)
推荐(0)
react子组件调用父组件的方法
摘要: class Parent extends Component { handleSth () { console.log('触发父组件成功') } render () { return ( <div> <Child childHandleSth={this.handleSth}></Child> </
阅读全文
posted @ 2020-02-23 20:38 panchunxin
阅读(474)
评论(0)
推荐(0)
2020年2月19日
mac 查看本机ip地址命令
摘要: ifconfig | grep "inet " | grep -v 127.0.0.1 inet后面的就是本机的ip地址
阅读全文
posted @ 2020-02-19 00:19 panchunxin
阅读(2829)
评论(0)
推荐(1)
下一页
公告