Clear the cache when the Vue project closes the browser

This project is to carry the token for verification request, reference use

App.vue page: use setToken according to your own definition

<script>
export default {
	name: "app",
	mounted(){
		//刷新页面时也会执行
        window.addEventListener('beforeunload',()=>{
            this.$store.dispatch("setToken", "");
        });
	}
}

</script>

 

Guess you like

Origin blog.csdn.net/SmartJunTao/article/details/108511449