NativeScript angular nativeView 未定义
NativeScript angular nativeView undefined
我正在尝试从 NativeScript Angular 获取 StackLayout
nativeView,但总是返回 undefined
。我这样试过:
html:
<StackLayout id="stackLayout" #stackLayout> </StackLayout>
TS:
ngAfterViewInit() {
setTimeout(() => {
let container: StackLayout = this.page.getViewById("stackLayout");
console.log(container.nativeView);
console.log(this.stackLayout.nativeElement.nativeView);
}, 100)
}
请给我建议。
使用视图本身的 loaded
事件确保 nativeView
准备就绪。
HTML
<StackLayout (loaded)="onLoaded($event)"></StackLayout>
TS
onLoaded(event: EventData) {
const stackLayout = <StackLayout>event.object;
console.log(stackLayout.nativeView);
}
我正在尝试从 NativeScript Angular 获取 StackLayout
nativeView,但总是返回 undefined
。我这样试过:
html:
<StackLayout id="stackLayout" #stackLayout> </StackLayout>
TS:
ngAfterViewInit() {
setTimeout(() => {
let container: StackLayout = this.page.getViewById("stackLayout");
console.log(container.nativeView);
console.log(this.stackLayout.nativeElement.nativeView);
}, 100)
}
请给我建议。
使用视图本身的 loaded
事件确保 nativeView
准备就绪。
HTML
<StackLayout (loaded)="onLoaded($event)"></StackLayout>
TS
onLoaded(event: EventData) {
const stackLayout = <StackLayout>event.object;
console.log(stackLayout.nativeView);
}