在App.vue文件中添加provide ,isRouterAlive。在需要刷新的页面添加inject: [“reload”],
<template>
<div id="app">
<router-view v-if="isRouterAlive" />
</div>
</template>
<script>
export default {
name: 'App',
provide () {
return {
reload: this.reload
}
},
data () {
return {
isRouterAlive: true
}
},
methods: {
reload () {
this.isRouterAlive = false
this.$nextTick(function () {
this.isRouterAlive = true
})
}
}
}
</script>
<style lang="scss">
@media (max-width: 1920px) {
body,
html {
font-size: 16px;
}
}
@media (max-width: 1680px) {
body,
html {
font-size: 14px;
}
}
@media (max-width: 1366px) {
body,
html {
font-size: 13px;
}
}
@media (max-width: 1360px) {
body,
html {
font-size: 13px;
}
}
@media (max-width: 1280px) {
body,
html {
font-size: 10px;
}
}
@media (max-width: 1024px) {
body,
html {
font-size: 9px;
}
}
</style>