属性'nativeElement',我在尝试将vimeo/player.js集成到我的angular-cli应用程序中时遇到了一些问题。vimeo/player.js - 无法读取标题中所述的未定义
由于我还没有发现对角4任何支持库,我以下在以下步骤中的README.md与模块捆绑使用。
我建VIMEO-player.component.ts:
import { Component, AfterViewInit, ViewChild} from '@angular/core';
import { Player } from '@vimeo/player';
@Component({
selector: 'app-vimeo-video-player',
templateUrl: './vimeo-player.component.html'
})
export class VimeoVideoComponent implements AfterViewInit {
@ViewChild('vimeoVideoContainer') vimeoVideoContainer;
public player: Player;
ngAfterViewInit() {
this.player = new Player(this.vimeoVideoContainer.nativeElement, {
id: 19231868, // Generic Id
width: 640
});
}
}
凡VIMEO-player.component.html:
<div id="vimeoVideoContainer"></div>
而且我想里面使用它另一个模板的组件。比如里面my.component.ts的模板,我有:
<app-vimeo-video-player></app-vimeo-video-player>
我越来越Cannot read property 'nativeElement' of undefined
甚至以为我设法利用ngAfterViewInit
。如果在触发new Player()...
之前设置了超时时间,则会发生同样的情况。
我在vimeo/player.js issues上发现了这个问题,但它没有帮助我。
编辑1:
随着@peinearydevelopment我解决了这个特别的错误,但现在我越来越:ERROR TypeError: __WEBPACK_IMPORTED_MODULE_1__vimeo_player__.Player is not a constructor
。
我在做什么错?我怎样才能解决这个问题?
你能解释一下为什么吗?无论如何,我得到另一个错误'StartNetworkComponent.html:2错误类型错误:__WEBPACK_IMPORTED_MODULE_1__vimeo_player __。播放器不是一个构造函数。 – AndreaM16
是的,我试图找到帮助解释的文档。 – peinearydevelopment