我在 Angular 6 中使用 ExcelJs Lib(1.12.0),但是这个 Lib 在开发中工作正常,但在生产中却不行,它在 workbook.xlsx.writeBuffer() 点失败。
import * as ExcelJS from "exceljs/dist/exceljs.min.js";
downloadExcelFile() {
const title = 'Titlename';
const header = 'headerdata'
const data = 'actualData';
let workbook = new ExcelJS.Workbook();
let worksheet = workbook.addWorksheet(title);
worksheet.addRow(header);
for(let d of data) {
worksheet.addRow(d);
}
workbook.xlsx.writeBuffer().then((data) => {
let blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const anchor = document.createElement('a');
const url = URL.createObjectURL(blob);
anchor.href = url;
anchor.download = title + '.xlsx';
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
URL.revokeObjectURL(url);
}).catch(err …Run Code Online (Sandbox Code Playgroud) 我是angular 4的新手,在编译时遇到错误
未捕获的错误:无法解析AllCountryComponent的所有参数:([对象对象],[对象对象] 、?)。在CompileMetadataResolver._getDependenciesMetadata(webpack-internal:///./node_modules/@angular/compiler/esm5/)的语法错误(webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:707)在CompileMetadataResolver._getTypeMetadata(webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:15762)处进行编译器.js:15927)
我还附有错误的屏幕截图:
我的allCountry.component.ts代码如下
import { Component, OnInit } from '@angular/core';
import { AppService } from '../../app.service';
import { ActivatedRoute, Route } from '@angular/router';
import {Location} from '@angular/common'
@Component({
selector: 'app-all-country',
templateUrl: './all-country.component.html',
styleUrls: ['./all-country.component.css'],
providers: [Location,AppService]
})
export class AllCountryComponent implements OnInit {
public name:string;
public value:string;
public listCountry:any[];
constructor(private http:AppService,private _route:ActivatedRoute ,_rout:Route ) {
console.log("allcountry constuctor are called");
}
ngOnInit() {
this.name=this._route.snapshot.paramMap.get('name');
this.value=this._route.snapshot.paramMap.get('value');
console.log(this.name);
console.log(this.value);
this.http.getAllCountry(this.name,this.value).subscribe(
data=>{
this.listCountry=data;
console.log(this.listCountry)
},
error=>{
console.log("error occured")
console.log(error.errorMessege)
}
) …Run Code Online (Sandbox Code Playgroud) img 标签在 img 不可用时抛出错误 404 而不是抛出错误我想要一个带有用户名第一个字符的 avtar 图像应该出现。假设用户名 Ravi 比 R 应该来而不是错误
我已经尝试过使用布尔标志,但它对我获取第一个字符不起作用,我在 alt 属性 list.name.charAt(0) 中尝试过,但仍然出现 img 错误
<ion-item lines="none">
<ion-thumbnail slot="start" rounded >
<ion-img [src]="'assets/icon/' +list?.type+ '.png'" >
</ion-img>
</ion-thumbnail>
<ion-text slot="end"></ion-text>
<ion-button (click)="doAdd(list.type ,'')" slot="end">
Add link
</ion-button>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
输出应该当 img 不可用时,用户名的第一个字符应该出现而不是错误