console.log('content_iframe', window.location) const _historyWrap = function (type) { const orig = history[type]; const e = new Event(type); return function () { const rv = orig.apply(this, arguments); e.arguments = arguments window.dispatchEvent(e) return rv } } history.pushState = _historyWrap('pushState') history.replaceState = _historyWrap('replaceState') window.addEventListener('hashchange', function () { getRouterType() }) window.addEventListener('popstate', function () { getRouterType() }) window.addEventListener('pushState', function () { getRouterType() }) window.addEventListener('replaceState', function () { getRouterType() }) let router_data = [] const getRouterType = () => { let key = history?.state?.key if (!key) { return } let index = router_data.indexOf(key) if (index < 0) { // 没有此页面 router_data.push(key) index = router_data.indexOf(key) } let type = '' if (router_data.length == 1) { type = 'first&last' } else if (index + 1 == router_data.length) { type = 'last' } else if (index == 0) { type = 'first' } return type }