我为屏幕创建了两个xml文件.一个名为"login-page.port.xml",另一个名为"login-page.land.xaml".
有没有办法以编程方式检测应用程序中的方向变化?
谢谢,凯克斯
我正在尝试使用类似于iMessage的布局创建消息传递视图,其中聊天"气泡"是其内容的大小,直到它达到一定的宽度.像这样:

使用nativescript,我无法找到适合这种情况的布局.我尝试使用GridLayout,但列的自动性质似乎意味着它将是内容的大小,即使内容的大小超出视图范围.
<GridLayout width="100%" columns="40, auto" rows="auto, 20" class="msg them" visibility="{{is_me ? 'collapsed' : 'visible'}}">
<Image class="authorimg" col="0" stretch="aspectFill" verticalAlignment="top" src="{{user.profile_photo ? user.profile_photo.sizes.tiny_square : ''}}" />
<StackLayout class="msg_text" col="1">
<Label text="{{message}}" textWrap="true" verticalAlignment="top" />
</StackLayout>
<Label class="msg_timestamp" text="{{author}}" verticalAlignment="top" row="1" colSpan="2" />
</GridLayout>
Run Code Online (Sandbox Code Playgroud)
这产生了这个:

请注意,尽管Label上的textWrap = true,但较长的不会换行.
硬币的另一面是这样的:
<GridLayout width="100%" columns="40, *" rows="auto, 20" class="msg them" visibility="{{is_me ? 'collapsed' : 'visible'}}">
<Image class="authorimg" col="0" stretch="aspectFill" verticalAlignment="top" src="{{user.profile_photo ? user.profile_photo.sizes.tiny_square : ''}}" />
<StackLayout class="msg_text" col="1">
<Label text="{{message}}" textWrap="true" verticalAlignment="top" /> …Run Code Online (Sandbox Code Playgroud) 对于该项目,我们当前正在使用带有angular2的本机脚本启动,单元测试对我们来说至关重要。因此,我首先尝试为给定的Groceries示例实现一些简单的操作,以使其更实用。非常简单的测试,例如测试电子邮件地址的验证是否正常,并且执行起来并不繁琐。一旦我开始进行更复杂的测试,就只有在涉及Testbed时才出现错误。
这是我在Testbed上执行的最简单的启动实现:
import "reflect-metadata";
import 'nativescript-angular/zone.js/dist/zone-nativescript';
import {TestBed} from '@angular/core/testing';
import { UserService } from "../../../shared/user/user.service";
declare var describe: any;
declare var expect: any;
declare var it: any;
declare var beforeEach: any;
describe('UserService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [UserService]
});
});
it("just testing", () => {
console.log('hier');
expect(false).toBe(false);
});
});
Run Code Online (Sandbox Code Playgroud)
这是我运行该错误时会收到的那种错误:
sampleGroceries[66839]: CONSOLE LOG file:///app/tests/shared/user/user.service.spec.js:13:20: hier
NativeScript / 10.0 (10.0; iPhone) A suite contains spec with an expectation FAILED
TypeError: undefined is not an object (evaluating 'ProxyZoneSpec.assertPresent') …Run Code Online (Sandbox Code Playgroud) 我正在尝试为Android创建一个Angular 2组件,用于显示特定路径的内容.为此,我创建了以下app-routing.module:
@NgModule({
imports: [
NativeScriptRouterModule.forRoot([
{ path: '', component: HomeComponent },
{ path: 'folder-content/:path', component: FolderContentComponent },
])
],
exports: [NativeScriptRouterModule]
})
Run Code Online (Sandbox Code Playgroud)
为了完整性,这里是folder-content.xml的xml
<StackLayout>
<GridLayout row="auto, *" row="2">
<ListView [items]="getContent(currentPath)">
<template let-item="item">
<GridLayout columns="auto, *" [nsRouterLink]="['/folder-content', item.path]">
<GridLayout columns="auto" rows="auto" cssClass="favorite-wrap">
<Image id="imgFav" [src]="item.isFile() ? 'res://ic_add_to_fav_1': 'res://folder'" stretch = "none" cssClass="icon-image"></Image>
</GridLayout>
<StackLayout col="1">
<Label [text]="item.name" cssClass="info-bigger"></Label>
<Label [text]="item.path" cssClass="info-orange"></Label>
</StackLayout>
</GridLayout>
</template>
</ListView>
</GridLayout>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
每次点击列表项时,我都想导航到同一页面,但是使用不同的参数(这可以按预期工作).
问题是当我尝试向后导航(使用物理后退按钮)时,我被重定向到HomeComponent而不是FolderContentComponent.
我尝试使用以下代码段打印路由器事件以获取更多信息:
router.events.forEach((event) => {
console.log(event);
});
Run Code Online (Sandbox Code Playgroud)
当从默认路径导航到 …
大约一年以来,我一直在业余爱好Angular 2 Web应用程序上工作,现在已经可以开始测试了。我想知道如何使用现有的angular 2代码并将其转换为本机脚本应用程序。我一直在研究本机脚本,看来您必须从一开始就使用本机脚本。我还使用了Angular cli和几个npm软件包来帮助开发我的应用程序。
已编辑
我在android模拟器中遇到问题,我的svg / icon图层显示为黑色。有时这会影响高速公路/道路标记以及我的地图标记。该插件当前正在使用默认标记,但是我也提供了自己的png文件,它们都遇到了这个问题。
有时放大会修复它(如下面图片中的一个标记所示)
我尚未在任何其他设备上对此进行测试,并且仅使用了来自android studio的android模拟器。
一些额外的细节
我正在使用Angular(和TS)运行nativescript,我已经注释掉了添加标记等的任何无关代码,但仍然在高速公路数字标记上存在问题(下面的示例)。这是我的模板:
<StackLayout class="page">
<ContentView height="100%" width="100%">
<Mapbox
accessToken="token"
mapStyle="streets"
[latitude]=defaultLocation.latitude
[longitude]=defaultLocation.longitude
hideCompass="true"
zoomLevel="8"
showUserLocation="false"
disableZoom="false"
disableRotation="false"
disableScroll="false"
disableTilt="false"
(mapReady)="onMapReady($event)">
</Mapbox>
</ContentView>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
看来我可以使用以下代码调用removeMarkers和addMarkers来触发此操作:
updateUserMarker(loc) {
console.log("updating user location marker with loc: ", loc)
this.map.removeMarkers([this.userMarker.id]);
this.userMarker.lat = loc.latitude;
this.userMarker.lng = loc.longitude;
this.map.addMarkers([this.userMarker]);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在需要API调用的Nativescript-vue后端laravel框架的位置上构建一个小型应用程序,以获取相关数据。例如,如果用户要登录,则需要通过api验证其凭据,oauth/token因此我尝试通过以下axios代码进行调用:
我的settings.js文件包含。
export const authHeader = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
Run Code Online (Sandbox Code Playgroud)
这是在我的axios调用中导入的:
const postData = {
grant_type: 'password',
username: user.email,
password: user.password,
client_id: clientId,
client_secret: clientSecret,
scope: '',
provider: provider
}
const authUser = {}
axios.post(authUrl, postData, {headers: authHeader}).then(response => {
console.log('Inside oauth/token url')
if(response.status === 200)
{
console.log('response received')
}
})
.catch((err) => {
if(err.response.status === 401){
reject('Validation error')
}
else
reject('Something went wrong')
})
Run Code Online (Sandbox Code Playgroud)
当我尝试使用命令进行构建时,tns debug …
我正在执行以下操作,将我的ipa文件上传到iTunes连接。
tns publish ios MY-ITUNES-ACCOUNT-EMAIL APP-SPECIFIC-PASSWORD -ipa app.ipa
我收到以下错误-红色
{
"serviceErrors" : [ {
"code" : "-20101",
"message" : "Your Apple ID or password was incorrect."
} ]
}
这曾经奏效-大约2-3周前。
我正在将Rails 5.2与Shrine gem一起用于图像上传。在客户端,我将NativeScript 6.0与Angular 8.0结合使用。
我已经安装了Shrine,并且可以在Rails端运行,并且可以通过Uppy直接上传。
在使用NativeScript的前端(Android移动设备)上,我可以拍摄一张照片(使用nativescript-camera),然后使用nativescript-background-http将其发送到nativescript-background-http演示服务器(基于节点)。
我遇到的问题是从NativeScript发送到Shrine。
在后端,我有这些路线
Rails.application.routes.draw do
resources :asset_items
mount ImageUploader.upload_endpoint(:cache) => "/images/upload" # POST /images/upload
end
Run Code Online (Sandbox Code Playgroud)
在神社里我有
require "shrine"
require "shrine/storage/file_system"
Shrine.storages = {
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"),
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads"), }
Shrine.plugin :logging, logger: Rails.logger
Shrine.plugin :upload_endpoint
Shrine.plugin :activerecord
Shrine.plugin :cached_attachment_data
Shrine.plugin :restore_cached_data
Run Code Online (Sandbox Code Playgroud)
在前端
onTakePictureTap(args) {
requestPermissions().then(
() => {
var imageModule = require("tns-core-modules/ui/image");
takePicture({width: 150, height: 100, keepAspectRatio: true})
.then((imageAsset: any) => {
this.cameraImage = imageAsset;
let image = new imageModule.Image();
image.src …Run Code Online (Sandbox Code Playgroud) 我正在使用nativescript和nativescript-dev-appium进行端到端测试,并且试图在文本字段中输入一些文本。
我的xml布局中的textField;
<StackLayout padding="10">
<Label text="Date of Purchase"></Label>
<DatePickerField hint="Select Date" [(ngModel)]="_dataItem.date_of_purchase"></DatePickerField>
</StackLayout>
<StackLayout padding="10">
<Label text="Name"></Label>
<TextField automationText="name" hint="Asset Name" [(ngModel)]="_dataItem.name" class="input">
</TextField>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
我的规格;
import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium";
import { assert } from "chai";
const addContext = require('mochawesome/addContext');
describe("sample scenario", () => {
let driver: AppiumDriver;
before(async function(){
nsCapabilities.testReporter.context = this;
driver = await createDriver();
});
after(async function () {
await driver.quit();
console.log("Quit driver!");
});
afterEach(async function () {
if (this.currentTest.state === "failed") …Run Code Online (Sandbox Code Playgroud) nativescript ×10
android ×3
angular ×3
javascript ×2
mobile ×2
appium ×1
axios ×1
ios ×1
jasmine ×1
label ×1
mapbox ×1
shrine ×1
typescript ×1
unit-testing ×1
vue.js ×1
xml ×1