【问题标题】:How to use chrome extension in Angular?如何在 Angular 中使用 chrome 扩展?
【发布时间】:2020-02-03 08:56:42
【问题描述】:

如何在我的 Angular 应用中使用 chrome?在我的 app.module 中

export const CHROME = new InjectionToken('CHROME');

providers: [...{ provide: CHROME, useValue: window.chrome } ...],

为我服务

/// <reference types="chrome"/>
import { chrome } from '@types/chrome';
constructor(  @Inject(CHROME) private chrome: chrome) {
  }

但我有一个错误:

TS2306:文件 'C:/Users/Sergey/Desktop/someProject/node_modules/@types/chrome/index.d.ts' 不是一个模块。 TS6137:无法导入类型声明文件。 考虑导入“chrome”而不是“@types/chrome”。

【问题讨论】:

标签: angular typescript google-chrome


【解决方案1】:

我不知道它有多正确,但它帮助了我:添加 .d.ts 文件,其中 'declare let chrome'。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-31
    • 1970-01-01
    • 2017-05-05
    • 2022-12-16
    • 1970-01-01
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多