diff --git a/src/keep-alive/withKeepAlive.js b/src/keep-alive/withKeepAlive.js
index aae1fe2..edc0167 100644
--- a/src/keep-alive/withKeepAlive.js
+++ b/src/keep-alive/withKeepAlive.js
@@ -1,22 +1,24 @@
import React, { useContext, useRef, useEffect } from 'react'
import CacheContext from './CacheContext'
import * as cacheTypes from './cache-types'
-const withKeepAlive = (OldComponent, { cacheId = window.location.pathname }) => {
+const withKeepAlive = (OldComponent) => {
const keepAliveWrapper = (props) => {
const { mount, cacheStates, dispatch } = useContext(CacheContext)
const ref = useRef(null)
useEffect(() => {
- const cacheState = cacheStates[cacheId]
+ const cacheState = cacheStates[props.match.url]
if (cacheState && cacheState.doms && cacheState.status !== cacheTypes.DESTROY) {
const doms = cacheState.doms
+ // 先清空 childNodes 再注入
+ ref.current.childNodes.forEach((child) => ref.current.removeChild(child))
doms.forEach((dom) => ref.current.appendChild(dom))
} else {
- mount({ cacheId, element: