開發環境 Angular8.1.0
,ng-zorro-antd:~8.0.2
,前端容器nginx:1.10.1
,瀏覽器 IE11
。html
// 問題: IE11 index.html文件打開後,頁面空白 // 解決: 更改tsconfig.json文件: { "compileOnSave": false, "compilerOptions": { "baseUrl": "./", ………… "target": "es2015", // 更改成es5 "lib": [ "es2018", "dom" ] }
// 問題: IE下new Date("2015-01-05 0:00:00") 會顯示NAN // 解決 用new Date("2015/01/05 0:00:00") 代替
// 安裝 npm install event-source-polyfill // 引入eventsource.min.js文件 import 'event-source-polyfill/src/eventsource.min.js' // ts const EventSource = NativeEventSource || EventSourcePolyfill; this.sse = new EventSource(url); // 鏈接sse服務器
// 問題:get請求後續會從瀏覽器緩存中讀取,沒法獲取最新數據。 // 解決:設置header const newReq = req.clone({ // 修改前端http攔截器 setHeaders: { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' } }); 或 add_header Cache-Control no-store; // 修改nginx配置
詳見 瀏覽器兼容性(三):IE瀏覽器http請求緩存問題nginx
// 問題: IE11不支持createObjectURL, 谷歌、火狐支持 a['href'] = urlObject.createObjectURL(new Blob([data]); a['download'] = name; // 解決: IE11用 msSaveBlob window.navigator.msSaveBlob(new Blob([data], name);
詳見 瀏覽器兼容性(四):本地下載npm
// 解決:修改polyfills.ts文件 /** IE10 and IE11 requires the following for NgClass support on SVG elements */ import 'classlist.js'; // Run `npm install --save classlist.js`.