我正在尝试为NativeScript构建联系人列表类型POC.我希望在列表项中有一个图像和名称.我用于布局的代码如下
<Page loaded="pageLoaded">
<ListView items="{{ myItems }}">
<ListView.itemTemplate>
<Image src="{{ imageSrc }}" />
<Label text="{{ title }}" />
</ListView.itemTemplate>
</ListView>
</Page>
Run Code Online (Sandbox Code Playgroud)
显然,标题值很好,但图像根本没有出现.当我尝试将相同的图像代码放在空白页面中时,NativeScript使用图像构建页面.
任何人都可以告诉我为什么图像不会出现在列表视图模板中?它怎么能显示出来?
谢谢
我有一个有动作栏和Tabview的应用程序.在tabview内部有一个列表视图.我想要的是当用户向下滚动列表时隐藏的操作栏,当用户向上滚动并且做得很好时弹出.作为一个例子,Android的youtube应用程序就是这样做的.
我已经尝试过这段代码 https://gist.github.com/vakrilov/6edc783b49df1f5ffda5但是当我隐藏栏时,屏幕底部会出现一个空白区域,所以在这种情况下不太有用.我尝试并且无法修改它并增加高度,因为我使用以下方法隐藏栏:
var params = userList.android.getLayoutParams();
params.height = 500;
userList.android.setLayoutParams(params);
userList.android.requestLayout();
Run Code Online (Sandbox Code Playgroud)
还有这个
var LayoutParams= android.view.ViewGroup.LayoutParams;
var params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Run Code Online (Sandbox Code Playgroud)
最后我出来了一种工作的东西但它突然没有动画隐藏/出现
var isChangingBar = false;
var isBarHidden = false;
userList.on("pan", function(args) {
var delta = args.deltaY;
console.log("deltaY: " + delta);
if (!isChangingBar) {
if (delta > 0 && isBarHidden === true) {
isChangingBar = true;
isBarHidden = false;
page.actionBarHidden = false;
isBarHidden = false;
setTimeout(function() {
isChangingBar = false;
}, 250);
}
else if (delta < 0 …Run Code Online (Sandbox Code Playgroud) 我在TextField中遇到数据绑定问题 ngModel
我有模特课
export class Product {
name: string
description: string
imageUrl: string
}
Run Code Online (Sandbox Code Playgroud)
视图:
<GridLayout backgroundColor="red">
<!--
This part is for logged users
-->
<StackLayout
[id]="container"
[visibility]="isLogged ? 'visible' : 'collapse'">
<Label text="Add product" textWrap="true"></Label>
<TextField
hint="product name"
[(ngModel)]="product.name">
</TextField>
<TextField
hint="product desc"
[(ngModel)]="product.description">
</TextField>
<Button text="Zrób zdj?cie produktu" (tap)="didTapTakePhoto()">
</Button>
<Button text="Wy?lij na serwer" (tap)="didTapSendProduct()">
</Button>
<Image #photo></Image>
</StackLayout>
<!--
This part is for not logged users
-->
<StackLayout [visibility]="isLogged ? 'collapse' : 'visible'">
<Label text="Musisz si? zalogowa?!" …Run Code Online (Sandbox Code Playgroud) 我有一个带有RadListView组件的nativescript-vue应用程序,用于向用户显示数据。列表的每一行都包含当前项目的多个信息。当我点击一个按钮以加载并显示列表时,UI冻结(快速硬件->短;慢速硬件->长)。我发现加载/合并数据的代码部分运行时间很短,但是UI元素的nativescript内部渲染或创建是问题所在。android控制台显示信息
I/Choreographer: Skipped 430 frames! The application may be doing too much work on its main thread.
Run Code Online (Sandbox Code Playgroud)
我看了stackoverflow和github,但是那里的问题(例如NativeScript Angular RadListView渲染速度非常慢)看起来相似,但是解决方案不适合我。
我使用LinearListView(而不是Grid或Stagged),也许在我的真实应用程序中,我将能够简化列表中的行元素,但在我的示例应用程序中(向下看),我将使用简单的行ui设计。
为了获得更简单,更好的报告,我在{N} -Playground上创建了一个示例应用程序。该应用程序将创建10000个数组元素并将其设置为RadListView的源,其中每个元素都有一个Label,一个Switch和一个ActivityIndicator。
I/Choreographer: Skipped 430 frames! The application may be doing too much work on its main thread.
Run Code Online (Sandbox Code Playgroud)
第一步,将在一个临时数组中生成10000个元素:
loadData() {
this.tmpAlarms = [];
for (let i = 0; i <= 10000; i++) {
this.tmpAlarms.push({
name: "Hase " + i,
active: i % 2 === 0, …Run Code Online (Sandbox Code Playgroud) radlistview nativescript nativescript-telerik-ui nativescript-vue
我想导航到另一个带参数的页面,但我似乎无法找到解释它的文档.我正在使用路线.这是我的路线的一个例子.
import { RouterConfig } from '@angular/router';
import { nsProvideRouter } from 'nativescript-angular/router';
import { MainPage } from './pages/main/main.component';
import { DetailsPage } from './pages/details/details.component';
export const routes: RouterConfig = [
{ path: "", component: MainPage },
{ path: "details", component: DetailsPage }
];
export const APP_ROUTER_PROVIDERS = [
nsProvideRouter(routes, {})
];
Run Code Online (Sandbox Code Playgroud)
我想使用在MainPage上选择的参数导航到DetailsPage.这是MainPage的摘录:
import { Page } from 'ui/page';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { Entity } from '../../shared/entity/entity';
@Component({
selector: "main",
templateUrl: "pages/main/main.html",
styleUrls: …Run Code Online (Sandbox Code Playgroud) 如何在驻留在应用程序中的页面之间共享数据.任何人都可以在nativescript中讲述localstorage吗?
我只是想安装NavtiveScript,为此,我按照官方安装指南进行操作
http://docs.nativescript.org/angular/start/quick-setup but I am stuck at "Step 3: Install iOS and Android requirements"
当我在命令提示符中运行以下命令时(具有管理权限)
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
Run Code Online (Sandbox Code Playgroud)
一切似乎安装没有任何问题.但是当我尝试通过命令验证安装时,"tns doctor"我返回以下警告:
D:\>tns doctor
WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies …Run Code Online (Sandbox Code Playgroud) 我正在使用带有角度2的nativescript。
我想知道如何在Nativescript项目中快速创建ng组件。例如,在Angular 2中创建我们正在使用的组件ng generate component hello。
是否有针对此的nativescript CLI解决方案?
我有以下客户:
new Client
{
ClientId = "nativeapptest",
ClientName = "Native App Test",
Enabled = true,
RequireClientSecret = false,
AllowedGrantTypes = GrantTypes.Code,
RedirectUris = { "com.mysite.nativeapp.12365789785256-buv2dwer7jjjjv5fckasdftn367psbrlb:/home" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"MyScope"
},
RequirePkce = false,
AllowOfflineAccess = true,
RequireConsent = false
}
Run Code Online (Sandbox Code Playgroud)
我使用本机脚本构建一个可以使用Identity Server 4登录的Android应用程序.目前发生的是我通过打开浏览器并使用所有正确的OpenID配置向IS4发出请求,最后我在登录屏幕上然后我选择使用Google登录.一旦进入谷歌,我输入我的电子邮件和密码,它一切都很好,然后谷歌试图将我送回我的网站,但它只是挂起...它的白页没有任何加载,它只是永远坐在那里,没有错误据我所知,is4记录的消息.
上面的nativescript登录部分来自OAutho2库https://www.npmjs.com/package/nativescript-oauth2
我试图理解这是IS4或原生Android应用程序的问题.页面是否挂起,因为它正在等待Android应用程序接管登录有效?Mabye问题在于RedirectURI计划?
它挂起的URL如下:
编辑:
由于我在实际的服务器上运行它,我无法直接调试它,但是,我确实添加了日志以查看代码的进度.我的日志告诉我用户已经通过谷歌和我的系统登录,我的日志也显示ExternalCallback已将页面重定向到
/connect/authorize/callback?client_id=nativeapptest&response_type=code&redirect_uri=com.mysite.nativeapp%3A%2F%2Fhome&scope=openid%20profile%20MyScope&response_mode=query&state=abcd
此时,页面挂起.
请注意,我们将RedirectUri更改为com.mysite.nativeapp以帮助进行测试.
最后,我不确定它是否重要,但我们没有使用https,因为这仍然是开发阶段.
我正在设置一个NativeScript-Angular项目,并想使用Jasmine-Karma实现单元测试,以便使用css选择器测试我的组件。如何为一个简单的组件设置一个简单的单元测试(除了官方存储库中提供的样本测试之外)?
这是针对使用带有Android API级别28的NativeScript CLI 6.0的新项目的。
我已经尝试使用常规的Angular TestBed,据称此博客文章支持它:https ://www.nativescript.org/blog/announcing-the-nativescript-4.1-release
我还尝试在官方nativescript-angular存储库上遵循他们的工作测试:https : //github.com/NativeScript/nativescript-angular/tree/master/tests
无论哪种方式,在尝试执行自己的实现时,我似乎都在做错事,因为出现以下错误:
Uncaught Error: Zone already loaded
TypeError: Cannot read property 'injector' of null
TypeError: Cannot read property 'getComponentFromError' of null
TypeError: Cannot read property 'currentPage' of undefined
有没有人设法让Jasmine-Karma在NativeScript中使用TestBed单元测试?
test-main.ts
import "nativescript-angular/zone-js/testing.jasmine";
import { nsTestBedInit } from "nativescript-angular/testing";
nsTestBedInit();
Run Code Online (Sandbox Code Playgroud)
example.ts
import { ItemsComponent } from '~/app/item/items.component';
import { By } from '@angular/platform-browser';
import { nsTestBedBeforeEach, nsTestBedAfterEach, nsTestBedRender } from 'nativescript-angular/testing';
describe('item-detail-component', () => {
beforeEach(nsTestBedBeforeEach(
[ItemsComponent] …Run Code Online (Sandbox Code Playgroud) nativescript ×10
angular ×3
typescript ×2
c# ×1
ios ×1
javascript ×1
listview ×1
navigation ×1
radlistview ×1
testbed ×1
xml ×1