react typescript 页面跳转state传参获取值
随着时间推移ts逐渐成为主流,以前jsx很多骚操作会受到类型检测的限制,虽然能正常运行,但是编辑器会提示各种错误。
比如这次要讲的react下页面跳转时利用state传参的功能
发起跳转
<Link
to={{ pathname: '/login', state: { userName: "xxoo" } }}
/>
接收参数
jsx写法
该写法在ts中其实也能获取到值。
const userName=props.location.state.userName;
注意:如果你用这.
原创
2021-04-05 00:00:06 ·
2273 阅读 ·
0 评论