首页 > 解决方案 > 错误类型错误:无法读取 null 的属性“querySelectorAll”和错误类型错误:无法读取 null 的属性“getElementsByTagName”

问题描述

*<div class="col-md-12" *ngIf="data_client2.length>0"> <button class="btn print" printSectionId="listVotantesPrint" ngxPrint i18n="@@downloadList"></button> '

<button class="btn csv ml-3" (click)="export('CSV', 'listVotantesPrint')"></button> 
 
<button class="btn excel ml-3" (click)="export('xls', 'listVotantesPrint')"></button> </div>

-------------------------------------------------- ----------------------* 组件.ts

 public export(type, element) {
    // console.log(element);
    this.exportAsConfig = {
      type: type, // the type you want to download
      elementIdOrContent: element, // the id of html/table element
    };
 

我尝试通过单击按钮在 csv 和 xml 中打印,但它给了我上述错误,我不知道为什么它这样告诉我。任何人都可以帮我解决这个问题

我正在使用角度 9“ngx-export-as”:“^1.5.0”,

标签: angularangular10

解决方案


仔细检查带有 id 的元素listVotantesPrint是否为 html 表格,csv 格式仅适用于表格


推荐阅读