定时删除localStorage

132 阅读1分钟
created() {
    if(this.$route.query.oid) { // 第一次使用路由传值,防止存储异步
        this.indent = this.$route.query.oid
        this.queryA()
    }else if(localStorage.getItem('oid')){ // 刷新使用本地存储
        if(localStorage.getItem('time') && new Date().getTime() - localStorage.getItem('time')>=172800000) {
            localStorage.removeItem('time')
            localStorage.removeItem('oid')
        }else {
            this.indent = localStorage.getItem('oid')
            this.queryA()
        }
    }
},