浏览器历史,判断是点击了后退按钮还是前进按钮

var history = this.state.history,
            pages = this.state.pages,
            l = history.length,
            hash = window.location.hash,
            position = "center";

        if (l === 0) {
            history.push(hash);
        } else if (hash === history[l - 2]) {
            history.pop();
            position = "left";
        } else {
            history.push(hash);
            position = "right";
        }

https://github.com/zyip/react/blob/master/src/main.js

原文地址:https://www.cnblogs.com/zyip/p/5237144.html