reactjs - React JS中用户注销时如何缓存清除
问题描述
import React, { Component } from "react";
export default class logout extends React.Component {
executeBasicAuthenticationService() {
}
logout(event) {
this.executeBasicAuthenticationService()
.then(() => {
sessionStorage.removeItem(USER_NAME_SESSION_ATTRIBUTE_NAME);
sessionStorage.clear();
window.location.href="/";
})
.catch(() => {})
}
解决方案
您可以将其放在 head 标记中以清除浏览器缓存:
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
如本文所述:
推荐阅读
- javascript - 用于收集对象属性、进行批处理并将结果映射回对象的 Javascript 库
- azure - 快速检测 VM 是否在 Azure 上运行
- html - 仅使用 HTML 在中间列中居中内容
- python - 如何有效地将字节转换为str
- java - 快速排序中的 StackOverflow
- angular - Angular 指令在滚动时向组件添加类?
- azure - 我是否在 Azure 无服务器功能中直接发送响应?
- postgresql - Yii2:如何为我的模型添加检查约束?
- cakephp - 将 VueJS 与 CakePHP 3 集成的最佳实践
- php - 使用 PHP 提取 JSON 数据