欢迎加入前端交流群交流知识获取视频资料:
兼容一(new Date()用法)
new Date('2018-01-01 00:00:00').getHours();
new Date('2018-01-01 00:00:00').getMinutes();
new Date('2018-01-01 00:00:00').getSeconds();
在IE11下需要这么写
let myMinTime = new Date('2018-01-01');
myMinTime.setHours(0);
myMinTime.setMinutes(0);
myMinTime.setSeconds(0); myMinTime.getHours();
myMinTime.getMinutes();
myMinTime.getSeconds();
兼容二(IE11下下载文件问题):
uA = window.navigator.userAgent;
isIE = /msie\s|trident\/|edge\//i.test(this.uA) && !!("uniqueID" in document || "documentMode" in document || ("ActiveXObject" in window) || "MSInputMethodContext" in window);
download(item) {
let param = {
param: item.url.toString()
}
this.upgradeService.download(param, {}, res => {
var a = document.createElement("a");
var blob = new Blob([res], {type: "application/octet-stream"});
a.href = URL.createObjectURL(blob);
a.download = item.fileName;
if (this.isIE) {
// 兼容IE11无法触发下载的问题
window.navigator.msSaveBlob(blob, item.fileName);
} else {
a.click();
}
});
}