鉴于此代码(来自其他人):
var module = angular.module('myApp', []);
module.controller('MyCtrl', function ($scope){
$scope.json = JSON.stringify({a:1, b:2});
});
module.directive('myDownload', function ($compile) {
return {
restrict:'E',
scope:{ data: '=' },
link:function (scope, elm, attrs) {
function getUrl(){
return URL.createObjectURL(new Blob([JSON.stringify(scope.data)], {type: "application/json"}));
}
elm.append($compile(
'<a class="btn" download="backup.json"' +
'href="' + getUrl() + '">' +
'Download' +
'</a>'
)(scope));
scope.$watch(scope.data, function(){
elm.children()[0].href = getUrl();
});
}
};
});
小提琴示例可以很好地在 chrome 中下载。但是点击“下载”链接在 IE11 中没有任何作用。没有错误,没有警告,根本没有响应。
但据此,它在 IE10 和 11 中受支持。
是否有一些 IE 安全设置需要更改或发生了什么?