我最近进入了nativescript,我遇到了一个我似乎无法解决的问题.
我想要完成的只是打开一个基本的WebView并设置一个外部URL来加载,如stackoverflow.com.
我在Android api 17的模拟器上运行它
app.js
var application = require("application");
application.mainModule = "main-page";
application.cssFile = "./app.css";
application.start();
Run Code Online (Sandbox Code Playgroud)
主page.js
var vmModule = require("./main-view-model");
var webViewModule = require("ui/web-view");
var webView = new webViewModule.WebView();
function pageLoaded(args) {
var page = args.object;
var web = page.getViewById(webViewModule.WebView,"webView");
web.url="http://google.com";
}
exports.pageLoaded = pageLoaded;
Run Code Online (Sandbox Code Playgroud)
主page.xml
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout>
<WebView id="webView" colSpan="4" row="2"/>
</StackLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)
我还检查了INTERNET权限是否设置为application,是的,启用了.
应用程序也停止工作,并且命令
tns运行android --emulator
在模拟器上成功安装并运行应用程序后,它只会发送大量输出.
你能帮助我理解究竟应该如何工作吗?
使用2.2获得以下异常.
正在使用以前的版本.
"tns info"和所有内容都更新为2.2
JS: Error: Uncaught (in promise): EXCEPTION: Error in pages/listview/listview.html:12:2
JS: ORIGINAL EXCEPTION: TypeError: _this.cssClasses(...).set is not a function
JS: ORIGINAL STACKTRACE:
JS: TypeError: _this.cssClasses(...).set is not a function
JS: at /data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:254:78
JS: at Array.forEach (native)
JS: at ViewUtil.setClasses (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:254:17)
JS: at ViewUtil.setPropertyInternal (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:189:18)
JS: at ViewUtil.setProperty (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:181:18)
JS: at NativeScriptRenderer.setElementProperty (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/renderer.js:141:23)
JS: at NativeScriptRenderer.setElementAttribute (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/renderer.js:145:21)
JS: at DebugAppView._View_ListviewPage0.createInternal (ListviewPage.template.js:58:17)
JS: at DebugAppView.AppView.create (/data/data/org.nativescript.test1/files/app/tns_modules/@angular/core/src/linker/view.js:87:21)
JS: at DebugAppView.create (/data/data/org.nativescript.test1/files/app/tns_modules/@angular/core/src/linker/view.js:299:44)
JS: ERROR CONTEXT:
JS: [object Object]
Run Code Online (Sandbox Code Playgroud) 我有这样的ListView
<ListView [items]="groceryList" row="1" class="small-spacing" [class.visible]="listLoaded">
<template let-item="item" columns="*, auto" >
<Label [text]="item.name" class="medium-spacing"></Label>
</template>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我想添加图片按钮.于是我就加入columns="*, auto"到template和
col="0"对标签和col="1"我Image
<ListView [items]="groceryList" row="1" class="small-spacing" [class.visible]="listLoaded">
<template let-item="item" columns="*, auto" >
<Label [text]="item.name" class="medium-spacing" col="0"></Label>
<Image src="res://delete" (tap)="delete(item.id)" col="1"></Image>
</template>
</ListView>
Run Code Online (Sandbox Code Playgroud)
运行模拟器后,我收到一个错误:
任何想法为什么会发生这种情况以及如何解决这个问题?
有没有一种简单的方法可以摆脱Nativescript Android应用程序中凸起按钮的默认阴影?我正在尝试创建一个微妙的按钮,但无法找到使按钮看起来平坦的方法.
我已经安装了NativeScript,tns platform add android但我尝试这样做,但它不起作用.ANDROID_HOME路径是正确的,我已经安装了SDK(API 22和最新版本)和工具(25.0.2).我跑的tns doctor时候说:
WARNING: The Android SDK is not installed or is not configured properly.
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=25.0.2'.
You need to have Android SDK 22 or later and the latest Android Support Repository …Run Code Online (Sandbox Code Playgroud) macos android android-sdk-tools nativescript angular2-nativescript
为了让我的NativeScript应用程序读取iOS上的联系人,我遇到了麻烦.我正在使用库nativescript-contacts来读取地址簿的所有条目和名为nativescript-permission的条目,以便询问用户是否有权阅读联系人.不幸的是,后者似乎只适用于Android,其中一切正常:出现弹出窗口要求用户允许阅读联系人,如果授予权限,则联系人显示在列表中.在iOS中,我无法请求联系人权限:没有弹出对话框,当我尝试使用nativescript-contacts的函数(例如getAllContacts())时,应用程序会冻结.
我试过搜索,但我唯一可以做的似乎是使用一些本机代码来获得这些权限......但我不知道如何.你可以帮我吗?
谢谢!
contacts user-permissions ios nativescript nativescript-plugin
我在Nativescript CLI上运行此命令
tns build ios --release
但不是构建.ipa文件.
如何构建.ipa文件?
我在nativescript-angular中的组件html文件中尝试了"hr"标记.但它没有在模拟器中显示水平线.(使用ios模拟器测试)
<StackLayout>
hr>
<Label horizontalAlignment="left" textWrap="true" text="Description" class="description-text"></Label>
</StackLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试找到一种方法来删除带有Angular 6应用程序的元素上的选项卡按钮,但到目前为止无济于事。基本上,我只想保留Tab的内容及其滑动功能。
显然,您可以使用特定的android和iOS方法,但是我不确定该怎么做。
<TabView [(ngModel)]="tabSelectedIndex" (selectedIndexChanged)="onSelectedIndexChanged($event)" (loaded)="tabViewLoaded($event)">
<ng-container *ngFor="let article of articles" #tabView>
<StackLayout *tabItem="{title: article.id}">
<StackLayout>
<NewsDetails></NewsDetails>
</StackLayout>
</StackLayout>
</ng-container>
</TabView>
Run Code Online (Sandbox Code Playgroud)
在我的.ts文件中,可以找到对元素的引用,如下所示:
@ViewChild("tabView") tabView: ElementRef;
ngAfterViewInit() {
console.dir(this.tabView.nativeElement);
}
Run Code Online (Sandbox Code Playgroud)
但是我不知道从现在开始该怎么做。有任何想法吗?以前与此有关的所有问题均未奏效。
这是一个示例游乐场链接:https : //play.nativescript.org/?template=play-ng&id=iK9ZTM
从版本5代码升级到Nativescript 6的最新版本后,开始在utils中给出ios的getter错误。属性“ getter”在类型“ ios类型”上不存在。在Nativescript 6中有角度。此代码负责在IOS上关闭键盘。
可通过官方文档而非方法进行检查 https://docs.nativescript.org/core-concepts/utils#ios
在不推荐使用Object属性访问运行utils.ios.getter()后也尝试获取错误;使用各自的本机属性,而不是utils.ios ['getter'](UIApplication,UIApplication.sharedApplication)
utils.ios.getter(UIApplication, UIApplication.sharedApplication)
.keyWindow
.endEditing(true);
Run Code Online (Sandbox Code Playgroud)
Getter应该在ios utils中可用