簡體   English   中英

app / app.component.ts(192,17):錯誤TS2339:類型'Intercom'不存在屬性'init'

[英]app/app.component.ts(192,17): error TS2339: Property 'init' does not exist on type 'Intercom'

  • 我正在嘗試將對講機npm軟件包包含在我的代碼庫中
  • 但是我遇到了錯誤。
  • 你們能告訴我如何解決嗎?
  • 在下面提供我的代碼段

app / app.component.ts(192,17):錯誤TS2339:類型'Intercom'不存在屬性'init'。

https://www.npmjs.com/package/ng-intercom

ngOnInit(): void {

    this.intercom.init({
        app_id: "mobilecode",
        // Supports all optional configuration.
        widget: {
            "activator": "#intercom" 
        }
    });
  • 因為我的代碼庫很大,所以在這里提供完整的代碼

https://hastebin.com/nafocafaze.js

在您的應用程序模塊中:

import { IntercomModule } from 'ng-intercom';

@NgModule({
  imports: [
    ...
    IntercomModule.forRoot({
      appId: <your_app_id>, // from your Intercom config
      updateOnRouterChange: true // will automatically run `update` on router event changes. Default: `false`
    })
  ...
  ]
})

我通過使用update()而不是init()使其工作(在1.0.0-beta.11中)。 我所做的就是更改ngOnInit()中的行

this.intercom.init({

this.intercom.update({

整個塊將如下所示:

ngOnInit() {
  this.intercom.update({
    app_id: <app_id>,
    // Supports all optional configuration.
    widget: {
      "activator": "#intercom"
    }
  });
}

希望這可以幫助!

(另一個快速修復程序將降級到init()起作用的1.0.0-beta.10。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM