📜  Angular json 文件和下载 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:45.949000             🧑  作者: Mango

代码示例1
constructor(private sanitizer: DomSanitizer){}

    generateDownloadJsonUri() {
        var theJSON = JSON.stringify(this.resJsonResponse);
        var uri = this.sanitizer.bypassSecurityTrustUrl("data:text/json;charset=UTF-8," + encodeURIComponent(theJSON));
        this.downloadJsonHref = uri;
    }