Angulartics2:类型"Angulartics2GoogleAnalytics"上不存在startTracking() [英] Angulartics2: startTracking() does not exist on type 'Angulartics2GoogleAnalytics'
问题描述
我已经按照
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.
推荐答案
我自己通过研究一些新文档遇到了同样的问题,但是后来我发现源
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) {}
}
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屋!