我一直在尝试使用nativescript创建一个Android应用程序.我正在使用fetch模块从我的服务器获取响应.当我试图从httpbin.org/get获得响应时,它没关系.但是当我试图获得响应时从我的本地服务器,我收到网络请求失败.错误.
发送到httpbin.org/get-
return fetchModule.fetch("https://httpbin.org/get").then(response => { return response.text(); }).then(function (r) {
console.log(r);
}, function (e) {
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
发送到localhost:8000/api-
return fetchModule.fetch("http://localhost:8000/api").then(response => { return response.text(); }).then(function (r) {
console.log(r);
}, function (e) {
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
当我尝试通过请求模块从localhost:8000/api获取纯node.js的响应.它工作正常.但是现在,我不知道如何使用fetch模块在nativescript中解决这个问题.
有没有人有NativeScript的经验,可以将它与开发本机应用程序进行比较,特别是对于Android?
我读过所有这些文章:
我知道其中有三个可能已经过时了.但我想问你所有的开发人员:
我有一次查询,不想保留一个监听器,以便在发送手动触发器时更新数据.
所以我的查询是这样的:
var ref = this.instance.child('/user/manish/today/events')
.orderByChild('endDateTime')
.endAt(endEventTime)
.limitToLast(10)
.addListenerForSingleValueEvent(this.previousEventListeners);
this.previousEventListeners = new com.google.firebase.database.ValueEventListener({
onDataChange: (snapshot) => {
console.log("Value from native firebase access");
console.dump(this.testing(snapshot.getValue()));
let result = {
value : this.testing(snapshot.getValue()),
type : "ValueChanged"
};
console.dump(result);
},
onCancelled: (databaseError) => {
console.log(databaseError.getMessage());
hideActivtiyIndicator();
}
});
Run Code Online (Sandbox Code Playgroud)
即使添加了与查询条件匹配的新记录,它也会返回相同的数据集.
谢谢
android firebase nativescript firebase-realtime-database angular2-nativescript
我对nativescript完全不熟悉并且谷歌搜索一些基本的东西比它应该更难...我想要做的基本上是这样的:我有这个号码
1234567.89
在变量中,我想在格式的标签中显示它
"1,234,567.89"
此外,如果89为0,则始终显示2位小数.
我在这里先向您的帮助表示感谢
您好我是NativeScript的新手,根据NativeScript网站上提供的文档,我创建了一个带有NativeSript + Angular的演示应用程序,并在设备上进行了部署,但是为了进行调试,我希望它能够像Chrome一样在Web浏览器上运行以获取应用程序的视图和调试.根据文档我能够在chrome中调试它但我可以获得应用程序的视图以在chrome中运行.有没有办法做到这一点.
我试图像这样在nativescript中更改进度组件的高度:
<Progress value="{{ progress }}" maxValue="{{totalTime}}" height="100">
</Progress>
Run Code Online (Sandbox Code Playgroud)
但是height属性无效。如何更改此组件的高度?
我刚开始使用Angular和NativeScript,对于我的生活,我无法弄清楚为什么我无法获得对组件的引用.
首先,我使用以下命令生成初始文件:tns create Test -ng.
接下来,我创建以下文件结构:
App_Resource
components
---app
------app.component.ts
---create
------create.component.ts
------create.component.html
app.module.ts
app.routing.ts
main.ts
Run Code Online (Sandbox Code Playgroud)
这是app.component.ts
import { Component } from "@angular/core";
import { Router } from "@angular/router";
@Component({
selector: "my-app",
template: "<page-router-outlet></page-router-outlet>"
})
export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)
这是create.component.ts
import { Component } from "@angular/core";
import { Location } from "@angular/common";
import { Router } from "@angular/router";
import * as AppSettings from "application-settings";
@Component({
selector: "create",
templateUrl: "./components/create/create.component.html",
})
export class CreateComponent …Run Code Online (Sandbox Code Playgroud) 在我的Nativescript Angular应用程序中,我在ScrollView中有一个TextView,其定义如下:
<ScrollView orientation="vertical" height="70%" width="100%" style="margin-bottom: 1%; background-color:white" (loaded)="onScrollerLoaded($event)">
<TextView
id="terminal" [text]="terminalText" editable="false"
style="color: whitesmoke; background-color: black; font-size: 8%; font-family: monospace" height="100%"
(tap)="onTap($event)" (loaded)="onTerminalLoaded($event)">
</TextView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
该元素的作用是充当终端,并快速打印来自蓝牙设备的传入消息。
当前,每当我terminalText向TextView绑定到的变量中添加一些文本时,ScrollView就会滚动回到顶部。我希望能够将ScrollView保留在TextView的底部。
一些注意事项:
我正在terminalText通过此方法向关联的组件类中的变量添加文本:
public appendToTerminal(appendStr){
this.terminalText += appendStr;
}
Run Code Online (Sandbox Code Playgroud)
我尝试实现以下代码,这些代码将在ScrollView加载后执行:
private scrollIntervalId;
onScrollerLoaded(data: EventData){
if(!this.scrollIntervalId){
this.scrollIntervalId = setInterval(()=>{
this.ngZone.run(() =>
(data.object as any).scrollToVerticalOffset((data.object as any).scrollableHeight, false)
)
}, 10);
}
}
Run Code Online (Sandbox Code Playgroud)
(此尝试基于此处给出的说明
我只能在Android设备上尝试此操作,因为我无法访问Apple设备。
在Angular中,实际上是使用env var加载到应用程序中的,environment.ts这是cli的一部分。
在NativeScript中,这似乎不适用于NativeScript cli。
最好的方法是什么?
我试图在我的Angular&Nativescript项目中使用Apache Thrift,但是通过'tns Preview --bundle'或任何其他tns命令,我得到了
TypeError: Cannot read property 'browser' of undefined
File: "<unknown>, line: 1, column: 265
Run Code Online (Sandbox Code Playgroud)
Apache Thrift版本0.11.0 / 1.0.0dev,Angular版本7.1.0,Nativescript版本5.1.0
在platform / android / app / src / main / assets / app / vendor.js中,我可以看到:
/* istanbul ignore next */
if (undefined.browser) {
defaultEncoding = 'utf-8'
} else {
var pVersionMajor = parseInt(undefined.version.split('.')[0].slice(1), 10)
Run Code Online (Sandbox Code Playgroud)
当我期望类似之类的东西时global.process.browser,我可以在vendor.js中找到另一种平静。在另一个平静中,我可以看到类似的东西undefined.nextTick(...)。我知道这是某种巴别塔问题,但我不知道如何解决。
我使用thrift --gen js:node脚本生成我的节俭文件(错误没有意义)。没有它们,所有的作品都很酷,但是后来我试图从Thrift执行任何Thrift生成的文件/任何模块,我在上面遇到了一个异常。my_component.ts
import { Component, OnInit } from '@angular/core';
import { TJSONProtocol } from 'thrift'; // or …Run Code Online (Sandbox Code Playgroud) nativescript ×10
android ×3
angular ×3
babel ×1
fetch-api ×1
firebase ×1
laravel-5.2 ×1
node.js ×1
telerik ×1
thrift ×1
typescript ×1
webpack ×1