如何在 angular2 中使用 nativescript 的 WebView? [英] How to use nativescript's WebView in angular2?
问题描述
我正在尝试在我的页面上插入一个 web-view 并收听loadFinishedEvent"...但是为了做到这一点,我需要在我的组件(ts文件)中找到webview,通过nativescript方式我需要用标签包装我的xml(UI):
I'm trying to insert a web-view on my page and listen the 'loadFinishedEvent'... But for do this, i need to find the webview in my component (ts file), through nativescript way i need to wrap my xml (UI) with a tag:
<Page xmlns="http://schemas.nativescript.org/tns.xsd
但是这样做我得到了这个错误:TypeError: this.page.frame._getNavBarVisible is not a function",如果没有 Page 标签,我已经尝试过一些方法,但没有成功......
But doing this i got this error: "TypeError: this.page.frame._getNavBarVisible is not a function", and without the Page tag i've already tried with some ways but with unsuccessful...
我也没有找到任何样本,有人可以帮助我吗?
I do not found any sample of this too, can anyone help me?
推荐答案
包含类实现的 .ts 文件
Your .ts file containing class implementation
import { Component } from "@angular/core";
@Component({
selector: "Date",
templateUrl: "myPage.html", //here is your reference to html page
})
export class Angular2WebView {
//any class function
}
您的 html 文件 myPage.html
Your html file myPage.html
<GridLayout>
<WebView id="webView" url="http://www.google.com" >
</WebView>
</GridLayout>
了解更多信息.请参阅此处 Nativescript 裸 webview 似乎不起作用
for more info. refer here Nativescript bare webview doesnt seem to work
这篇关于如何在 angular2 中使用 nativescript 的 WebView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!