Angular在IE 11中的GET请求从缓存中获取数据。
创始人
2024-10-30 20:00:55
0

在Angular中,可以使用http请求的cache选项来控制是否从缓存中获取数据。

以下是一个示例代码,展示如何在IE 11中使用Angular进行GET请求并从缓存中获取数据:

import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Component({
  selector: 'app-example',
  template: `
    
    
{{ item }}
`, }) export class ExampleComponent implements OnInit { data: any[]; constructor(private http: HttpClient) {} ngOnInit() {} getData() { const url = 'https://api.example.com/data'; // 替换为实际的API URL const headers = new HttpHeaders() .set('Cache-Control', 'no-cache') // 禁用缓存 .set('Pragma', 'no-cache') .set('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT'); this.http .get(url, { headers, responseType: 'json', withCredentials: true }) .subscribe((response) => { this.data = response; }); } }

在上述代码中,我们通过设置请求头中的Cache-ControlPragmaExpires来禁用缓存。这样,即使在IE 11中,GET请求也不会从缓存中获取数据。

相关内容

热门资讯

玩家实测!wepoker有辅助... 玩家实测!wepoker有辅助插件吗,wepoker透视脚本是什么,切实真的是有挂(有挂总结)1、打...
科普分享!wpk可以作弊吗,h... 科普分享!wpk可以作弊吗,hhpoker德州有挂吗,原来是有挂(有人有挂)1、进入到是否有挂之后,...
玩家必看科普!wepoker手... 玩家必看科普!wepoker手机插件,hhpkoer辅助器视频,原来真的有挂(有挂讲解)1、用户打开...
玩家必看秘籍!wpk真吗,we... 玩家必看秘籍!wpk真吗,we poker免费辅助器,其实真的有挂(有挂技巧)1、有没有辅助教程、有...
玩家必看攻略!fishpoke... 玩家必看攻略!fishpoker透视,德普辅助app,竟然真的是有挂(有挂实锤)1、玩家可以在透视最...
实操分享!aapoker透视怎... 实操分享!aapoker透视怎么用,wepoker免费脚本,原来是真的有挂(有挂助手)1、进入游戏-...
我来教教你!hhpoker有后... 我来教教你!hhpoker有后台操控吗,wepoker透视最简单三个步骤,都是有挂(有挂方略)所有人...
必备教程!aapoker破解侠... 必备教程!aapoker破解侠是真的吗,微扑克游戏辅助器,切实是有挂(有挂功能)1)有没有挂:进一步...
玩家必看科普!微扑克辅助,we... 玩家必看科普!微扑克辅助,wepoker辅助器最新版本更新内容,都是是有挂(竟然有挂)1、进入到we...
最新技巧!aapoker辅助器... 最新技巧!aapoker辅助器怎么用,aapoker脚本,好像是真的有挂(有挂方式)亲,关键说明,透...