Pārlūkot izejas kodu

addEventListener pageshow

bzkf3 2 gadi atpakaļ
vecāks
revīzija
0390c1d054
1 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 6 1
      src/pages/step/[id].vue

+ 6 - 1
src/pages/step/[id].vue

@@ -320,13 +320,18 @@ function routerPush(path: RouteLocationRaw) {
 }
 function windowPushState(path: string) {
   // !未启用
-  // 采取如下方式主要由于chrome下history.back()不会重新load页面
   sessionStorage.setItem('historyLocation', location.href)
   window.open(`${location.origin}/${path}`, '_self')
   // location.replace(`${location.origin}/${path}`)
   // window.history.pushState(null, '', `${location.origin}/${path}`)
 }
 
+// 采取如下方式主要由于chrome下history.back()不会重新load页面
+window.addEventListener('pageshow', (e) => {
+  if (e.persisted)
+    window.location.reload()
+})
+
 function handleValidTask(currentStep: number, idx: number, idy: number) {
   let lastIdx = idx
   let lastStep = currentStep