标签: nativescript

Nativescript:如何扩展ObservableArray?

为什么我会收到以下错误?

通用类型'ObservableArray需要1个类型参数

这是我的代码:

import {ObservableArray} from 'data/observable-array';

export class BaseCollection<T> extends ObservableArray {
}
Run Code Online (Sandbox Code Playgroud)

typescript nativescript

1
推荐指数
1
解决办法
372
查看次数

Nativescript将摄像头捕获发送到服务器

在我的Nativescript应用程序中,我想使用相机模块捕获图像,然后通过http调用将字节直接发送到服务器.

这是我的代码(为简洁起见不完整):

var cameraModule = require("camera");
var http = require("http");
...

cameraModule.takePicture().then(function (img) {
  // how to extract the actual bytes from img???
  
  http.request({
    url: some_url,
    method: "POST",
    headers: { "Content-Type": "application/octet-stream" },
    content: ???
  });
});
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

我正在查看nativescript-background-http,它似乎完全符合我的要求,但该示例显示了仅从路径加载的文件.我没有运气使这个在iOS上运行.

任何帮助是极大的赞赏.

谢谢.

nativescript

1
推荐指数
1
解决办法
2030
查看次数

nativescript在后端web api进行身份验证

我是移动开发的新手.我的项目是使用asp.net构建的.对于身份验证我正在使用构建它UserManager和User.Identity.

我有一堆现有的网络api,我希望从移动应用程序中使用它们.我知道,我可以在验证后将秘密哈希传递给web api,但这将涉及巨大的代码重构.

我一直想知道是否还有其他方法可以使用nativescript和asp.net处理身份验证和授权.

你知道这个主题的任何有用资源吗?

非常感谢您的帮助!

asp.net authentication asp.net-mvc nativescript angular

1
推荐指数
1
解决办法
1736
查看次数

Nativescript - XSS预防

使用Nativescript编写的移动应用程序(使用跨平台Javascript运行时)是否与网站具有相同的XSS漏洞?

xss nativescript

1
推荐指数
1
解决办法
176
查看次数

Nativescript WebView捕获onclick事件

我需要捕获WebView上的tap(单击)事件(以在SVG文件中显示图片),以便可以根据单击图像的位置显示另一个Nativescript页面(或显示另一个SVG)。

有没有一种方法可以为WebView捕获带有x,y坐标的轻击事件?

另一件事。我发现WebView可以捕获加载的html中的超链接...有没有办法在html中建立链接,以便它在nativescript应用程序中打开另一个本地文件?例如:<a href =“〜/ stuff / foo2.html”>此处</ a>,但是没有用(东西在我的“ app”文件夹下),但是我得到了404。

nativescript

1
推荐指数
1
解决办法
1527
查看次数

如何显示和绑定base64字符串作为Nativescript中的源?

我试图在我的视图中显示并将base64图像绑定为ImageSource,但它根本没有显示.我在文档中找不到任何有用的信息..我做错了吗?

imageSource是应该保存Image src数据的属性.

这是视图:

<Page loaded = "loaded" xmlns = "http://schemas.nativescript.org/tns.xsd" >
    <StackLayout>
        <TextField hint = "String for encoding!" text = "{{ message }}" />
        <Button  tap = "{{ onGenerateQrTap }}" text = "Generate QR" class = "button" />
        <Image src = "{{ imageSource }} " />
    </StackLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)

这是View背后的代码:

import { Page } from 'ui/page';
import { EventData } from 'data/observable';
import { QrGeneratorViewModel } from '../../ViewModels/QrGeneratorViewModel';
import { Button } from 'ui/button';
import { Image } from 'ui/image'; …
Run Code Online (Sandbox Code Playgroud)

android typescript nativescript

1
推荐指数
1
解决办法
745
查看次数

NativeScript Android API版本检查

我使用以下命令将android平台添加到我的nativescript应用程序

tns platform add android

现在我无法弄清楚该平台的哪个API版本被添加了?

我怎么能搞清楚这一点?

nativescript angular2-nativescript

1
推荐指数
1
解决办法
2072
查看次数

如何在NativeScript移动应用程序中引用本地文件

我试图从位于项目结构中的.txt文件中读取.将应用程序编译到设备(在Android和iOS上都经过测试)后,我首先检查文件是否存在.它似乎没有.

fileAccess.ts:

import fs = require("file-system");

export class FileAccess
{
    public data(filePath: string)
    {
        let exists = fs.File.exists(filePath);
        console.log(exists);
    }
}
Run Code Online (Sandbox Code Playgroud)

test.txt(与fileAccess.ts位于同一目录中):

1;DAC
Run Code Online (Sandbox Code Playgroud)

调用data("./test.txt");一个实例FileAccess,控制台打印错误.

我假设我引用文件错误,或者文件没有​​被复制到设备.但是它是什么,我该如何解决它?

android ios nativescript

1
推荐指数
1
解决办法
511
查看次数

安装100+ MB后的Nativescript应用程序大小

当我构建一个{N}应用程序时,ipa或apk文件大小为30MB

tns build ios --release --for-device
Run Code Online (Sandbox Code Playgroud)

并且在上面构建的设备中安装应用程序后,设备的大小为100MB +.任何人都可以帮我这里如何减少应用程序的大小?

- 编写问题在浏览webpack之后,

---我升级到nativescript(2.5.2),angular(2.4.5)和核心模块(2.5.1),将应用程序与webpack(2.2.0)捆绑在一起,app成功运行/捆绑,生成的ipa (与android debug-apk大小相同)在命令下运行时文件大小为21.3MB

npm run build-ios-bundle --release --for-device 
Run Code Online (Sandbox Code Playgroud)

但是当应用程序安装在设备/ iTunes中时,应用程序的大小显示为53MB 在此输入图像描述

53MB的应用程序大小也非常庞大,任何人都可以帮助我在这里如何减少应用程序的大小,即使在webpack集成之后.我正在分享我的package.json

{
  "description": ".....",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": ".....",
  "repository": ".....",
  "nativescript": {
    "id": "......",
    "tns-ios": {
      "version": "2.5.0"
    }
  },
  "dependencies": {
    "@angular/common": "~2.4.5",
    "@angular/compiler": "~2.4.5",
    "@angular/core": "~2.4.5",
    "@angular/forms": "~2.4.5",
    "@angular/http": "~2.4.5",
    "@angular/platform-browser": "~2.4.5",
    "@angular/platform-browser-dynamic": "~2.4.5",
    "@angular/router": "~3.4.5",
    "moment": "^2.17.1",
    "nativescript-angular": "1.4.1",
    "nativescript-angular-snapshot": "1.3.0-5.2.361",
    "nativescript-cardview": "^1.2.1",
    "nativescript-carousel": "^2.2.0",
    "nativescript-dom": "^1.0.8",
    "nativescript-fresco": "^1.0.16",
    "nativescript-imagepicker": "^2.4.1",
    "nativescript-iqkeyboardmanager": "^1.0.1",
    "nativescript-pdf-view": …
Run Code Online (Sandbox Code Playgroud)

nativescript angular2-nativescript

1
推荐指数
1
解决办法
2371
查看次数

如何在listview angular2 nativescript中解析这个json结构

json结构:

{
  "Employee": [
       {"id":1,"name":"Dan" },
       {"id":2,"name":"Stack" },
       .....
    ]
}
Run Code Online (Sandbox Code Playgroud)

app.component.ts:

 ngOnInit() {
 console.log("first", "Test");

    this.globalReader.getObjectData()
      .subscribe(data => this.getData = JSON.stringify(data),  ---> Response printed successfully here.I'm able to print it in label.
       error => alert(error),
       () => console.log("finished")

      );      

  }
Run Code Online (Sandbox Code Playgroud)

编辑:

零件:

  <label text ="{{getData }}" ></label>



  getObjectData() {

    return this._http.get('/page/emp.json')
      .map((response :Response) => response.json());

  }  
Run Code Online (Sandbox Code Playgroud)

之后,我不知道如何解析json并在listview中为此结构打印它.我提到了一些视频和杂货申请.但我仍然无法得到结果.我非常困惑arrayname员工.

我需要name在listview中只打印from响应.

typescript nativescript angular2-services angular2-nativescript angular

1
推荐指数
1
解决办法
1036
查看次数