![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
react
weixin_30980795
Don't repeate youself
展开
-
react-router
一、基本用法React Router 安装命令如下。 npm install -S react-router使用时,路由器Router就是React的一个组件。import { Router } from 'react-router';render(<Router/>, document.getElementById('app'));Router组件本身只是一个容器,真正的路由要通过Route组件定义。import { Router, Route, hashHistory }转载 2020-11-10 15:53:12 · 143 阅读 · 0 评论 -
react 页面缓存两种方式
项目需要:切换组件保留前一个页面数据,即:返回上一页的时候,上一页的滚动条、动作状态等等和离开这个页面时的状态保持一致。1.react路由处理方式用react-router-cache-route插件替代react-router-dom插件,2.全局状态管理;1. 路由实现方式参考这篇文章https://www.jianshu.com/p/a9e16b9eb2102. 全局状态实现方式这方法就很简单了,只需要在根组件注入一个全局状态即可在网页没关闭情况下,保留页面数据。...原创 2020-10-11 17:59:59 · 5823 阅读 · 0 评论