首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >app/app.component.ts(192,17):错误TS2339:属性'init‘在'Intercom’类型中不存在

app/app.component.ts(192,17):错误TS2339:属性'init‘在'Intercom’类型中不存在
EN

Stack Overflow用户
提问于 2018-01-17 08:26:31
回答 2查看 498关注 0票数 1
  • 我正试图在我的代码库中包括对讲npm包。
  • 但我的错误越来越少了。
  • 你们能告诉我怎么修吗。
  • 提供下面的代码片段

app/app.component.ts(192,17):error TS2339:属性'init‘在'Intercom'.类型中不存在

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

代码语言:javascript
复制
ngOnInit(): void {

    this.intercom.init({
        app_id: "mobilecode",
        // Supports all optional configuration.
        widget: {
            "activator": "#intercom" 
        }
    });
  • 提供完整的代码,因为我的代码库很大

https://hastebin.com/nafocafaze.js

EN

回答 2

Stack Overflow用户

发布于 2018-01-17 10:14:53

在你的应用模块中:

代码语言:javascript
复制
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`
    })
  ...
  ]
})
票数 1
EN

Stack Overflow用户

发布于 2018-01-26 13:21:24

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

从…

代码语言:javascript
复制
this.intercom.init({

代码语言:javascript
复制
this.intercom.update({

然后整个块看起来如下:

代码语言:javascript
复制
ngOnInit() {
  this.intercom.update({
    app_id: <app_id>,
    // Supports all optional configuration.
    widget: {
      "activator": "#intercom"
    }
  });
}

希望这能有所帮助!

(另一个快速修复方法是将init()确实工作的级别降到1.0.0-beta.10。)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48296578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档