Angular:成员不可调用
发布时间:2020-12-17 08:32:58 所属栏目:安全 来源:网络整理
导读:我将导入的函数分配给构造函数中的组件属性,以便在模板中使用它. 构建正确,但在我的编辑器(带有Angular语言服务的Visual Studio代码)中,显示以下错误. 下面是我导出的函数的代码. export function downloadFile(fileUrl: string,fileName: string) { let a =
我将导入的函数分配给构造函数中的组件属性,以便在模板中使用它.
构建正确,但在我的编辑器(带有Angular语言服务的Visual Studio代码)中,显示以下错误. 下面是我导出的函数的代码. export function downloadFile(fileUrl: string,fileName: string) { let a = document.createElement('a'); a.href = fileUrl; a.download = fileName; a.click(); } 下面是我在组件中的代码. import { downloadFile } from '../../shared/utilities'; @Component({ ... }) export class SomeComponent { downloadFile: any; constructor() { this.downloadFile = downloadFile; } } 我无法理解为什么会出现此错误.请帮忙!
我认为不是在组件文件中以这种方式声明下载文件
下载文件:任何; 你应该这样声明 downloadFile :()=>任何; 检查一下是否有帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |