Angulartics2:类型"Angulartics2GoogleAnalytics"上不存在startTracking() [英] Angulartics2: startTracking() does not exist on type 'Angulartics2GoogleAnalytics'

查看:92
本文介绍了Angulartics2:类型"Angulartics2GoogleAnalytics"上不存在startTracking()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照自述文件中的说明进行操作. ="https://github.com/angulartics/angulartics2" rel ="nofollow noreferrer"> Angulartics2 用于Google Analytics(分析):

I've followed the instructions on the readme of Angulartics2 for Google Analytics:

app.module.ts:

import { Angulartics2Module } from 'angulartics2';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
...
imports: [Angulartics2Module.forRoot([Angulartics2GoogleAnalytics])

app.component.ts

import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
...
constructor(
    angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics
) {
    angulartics2GoogleAnalytics.startTracking();
}

angulartics2GoogleAnalytics.startTracking()会引发错误: Angulartics2:"Angulartics2GoogleAnalytics"类型上不存在startTracking().

angulartics2GoogleAnalytics.startTracking() throws an error though: Angulartics2: startTracking() does not exist on type 'Angulartics2GoogleAnalytics'.

谁能告诉我为什么?我正在使用Angular 5.2.8.

Can anyone tell me why? I'm using Angular 5.2.8.

推荐答案

我自己通过研究一些新文档遇到了同样的问题,但是后来我发现源startTracking() https://github.com/angulartics/angulartics2/blob/master/src/lib/providers/ga/ga.ts"rel =" nofollow noreferrer> https://github.com/angulartics/angulartics2/blob/master/src/lib/providers/ga/ga.ts

I had the same issue myself by looking in to some new docs but then I just figure out there is no startTracking() in the sources https://github.com/angulartics/angulartics2/blob/master/src/lib/providers/ga/ga.ts

另请参阅 https://github.com/angulartics/angulartics2/wiki/Google Analytics(分析)

export class AppComponent {
  constructor(angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics) {}
}

更新:startTracking()存在于

UPDATE: the startTracking() exists on the next branch through, added 6 days ago. The next branch does not released as a new version yet so the package version you are getting from npm does not contain any new code from the next branch.

这篇关于Angulartics2:类型"Angulartics2GoogleAnalytics"上不存在startTracking()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆