gpt4 book ai didi

angular7 - Angular 7 中的 declarations.d.ts

转载 作者:行者123 更新时间:2023-12-05 08:07:31 25 4
gpt4 key购买 nike

几天前,我切换到 Angular 7,但无法找到 declarations.d.ts。

在 Angular 2 和 4 中,我使用 declarations.d.ts 来定义 JQUERY 和其他类型的类型 -

interface JQuery {
datepicker(options: any): JQuery;
modal(options: any): JQuery;
}

在 Angular 7 中在哪里定义未知元素接口(interface)?

注意:我使用 Angular CLI 生成项目。

最佳答案

/src 文件夹中使用 typings.d.ts

更多信息在这里:TypeScript Configuration

更新

实现目标的更好方法是使用 jQuery's typings .请务必添加:

"typeRoots": [
"node_modules/@types"
],

到您的 tsconfig.json 以便 typescript 知道在哪里搜索类型。大多数著名的库都会有他们的 typings 包,所以首先尝试从 npm 获取它,如果找不到,那么您总是可以在 typings.d.ts

中定义它们

关于angular7 - Angular 7 中的 declarations.d.ts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54995976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com