<template>
<div id="main" class="app-main">
<router-view></router-view>
</div>
</template>
<script>
export default {
data () {
return {
theme: this.$store.state.app.themeColor
};
},
mounted () {
},
beforeDestroy () {
},
methods: {
},
mounted(){
// 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
window.onbeforeunload = function (e) {
var storage = window.localStorage;
storage.clear()
}
}
};
</script>
<style>
html,body{
width: 100%;
height: 100%;
background: #f0f0f0;
overflow: hidden;
}
.app-main{
width: 100%;
height: 100%;
}
如果是多页面的程序的话,在每一个页面同理只要在mounted方法中,注册这个事件即可!