a1300399510@qq.com 提交于 2023/04/06 -18:00:01

This commit is contained in:
XiaoMo 2023-04-06 18:00:11 +08:00
parent 0ede88dce0
commit 7c79f44ace
2 changed files with 4 additions and 26 deletions

View File

@ -1,9 +1,7 @@
<template>
<div id="app">
<div class="container">
{{ a }}
<!-- <router-view /> -->
<router-view />
</div>
</div>
@ -14,34 +12,12 @@ export default {
name: "App",
data() {
return {
a: 1
}
},
mounted() {
this.$store.dispatch('fetchHistoricalSearch')
this.a = localStorage.getItem("a") || "默认"
// console.log(this.a);
window.addEventListener("beforeunload", () => {
localStorage.setItem("a", Number(this.a) + 1)
})
window.addEventListener("pagehide", () => {
localStorage.setItem("a", Number(this.a) + 1)
})
window.addEventListener("visibilitychange", () => {
localStorage.setItem("a", Number(this.a) + 1)
})
window.addEventListener("popstate", () => {
localStorage.setItem("a", Number(this.a) + 1)
})
},
beforeDestroy(){
localStorage.setItem("a", Number(this.a) + 1)
}
}
</script>

View File

@ -11,7 +11,7 @@ export default new Vuex.Store({
},
mutations: {
setHistoricalSearch(state, payload) {
console.log(payload, "payload");
// console.log(payload, "payload");
// payload = [...new Set(payload)]
state.historicalSearch = payload
// localStorage.setItem('historicalSearch', JSON.stringify(payload));
@ -26,5 +26,7 @@ export default new Vuex.Store({
},
modules: {
}
})