react缓存页面内容 插件react-router-cache-route

缓存页面内容,跳到下一页再次返回,滚动,点击active都保持和离开时候的状态一致

npm install react-router-cache-route --save

示例代码:

import React from "react";
import ReactDom from "react-dom";
import { HashRouter, Route, hashHistory, Redirect } from "react-router-dom";
import {CacheSwitch, CacheRoute} from 'react-cache-router';
class App extends React.Component {
    constructor(props) {
        super(props)
    }
    render() {
        return ( 
                
                    
                        
                        
                        
                    
                
        )
    }
}
ReactDom.render(, document.getElementById("root"));

注意:
缓存语句要写在CacheSwitch里面

你可能感兴趣的:(react缓存页面内容 插件react-router-cache-route)