【发布时间】:2017-12-22 17:06:14
【问题描述】:
库内失败,tns_modules 中的inside the prototype method,我猜this._android 未定义。
_createUI() 似乎从未被调用过。
错误:
TypeError:无法读取未定义的属性“addHeart” 文件:“file:///data/data/org.nativescript.bbnsng210June/files/app/tns_modules//bundles/core.umd.js,行:13024,列:8
堆栈跟踪: 框架:函数:'PeriscopeHearts.addHeart',文件:'file:///data/data/org.nativescript.bbnsng210June/files/app/tns_modules/nativescript-periscopehearts/periscopehearts.js',行:19,列:22 框架:函数:'WebRtcViewComponent.newHeart',文件:'file:///data/data/org.nativescript.bbnsng210June/files/app/modules/webrtcview/webrtcview.component.js',行:39,列:24 框架:函数:'',文件:'',行:81,列:24 框架:函数:'handleEvent',文件:'file:///data/data/org.nativescript.bbnsng210June/files/app/tns_modules//bundles/core.umd.js',行:11805,列:138
调用代码是这样的:
@ViewChild('heartLayout') heartLayout_el: ElementRef;
ngAfterViewInit(): void {
this.peri_heart_el_native = <PeriscopeHearts>(this.heartLayout_el.nativeElement);
alert('this.peri_heart_el_native:' + this.peri_heart_el_native); //PeriscopeHearts(771)
}
newHeart() {
let colorArray = [{ hex: "#3489db" }, { hex: '#FF4081' }, { hex: '#229911' }, { hex: '#fff000' }];
let rand = colorArray[Math.floor(Math.random() * colorArray.length)];
this.peri_heart_el_native.addHeart(rand.hex);
}
和模板:
<side-drawer-page>
<StackLayout class="coverImage">
<Button text="Add Heart" (tap)="newHeart()"></Button>
<PeriscopeHearts #heartLayout class="heartLayout" height="400">
</PeriscopeHearts>
</StackLayout>
</side-drawer-page>
PS:plugin 上的 github 问题已经创建,但它更多的是角度问题,而不是特定于插件的问题,因此在此处复制。
【问题讨论】:
标签: angular nativescript angular2-nativescript