天气这么好,欢迎光临阁下小站

0%

我将总结react在这里

Quick Start

1.react路由传参

xxx this.props.history.push({pathname:"/path/" + name}); 读取参数用:this.props.match.params.name

优势 : 刷新地址栏,参数依然存在
缺点:只能传字符串,并且,如果传的值太多的话,url会变得长而丑陋。

2.query

this.props.history.push({pathname:"/query",query: { name : 'sunny' }}); 读取参数用: this.props.location.query.name

优势:传参优雅,传递参数可传对象;
缺点:刷新地址栏,参数丢失

3.state

this.props.history.push({pathname:"/sort ",state : { name : 'sunny' }}); 读取参数用: this.props.location.query.state

优缺点同query

xxx this.props.history.push({pathname:"/web/departManange?tenantId" + row.tenantId}); 读取参数用: this.props.location.search

转自:https://www.jianshu.com/p/ad8cc02b9e6c

第二