标签: nativescript

在NativeScript中以backgound运行任务

我正在使用NativeScript 2.0,我正在开发一个不允许在主线程中运行Android模块!

是否有一个模块可用于在后台线程中运行函数?

或者是否可以在"本机"JavaScript代码(非TypeScript!)中使用类似AsyncTask类的东西?

javascript multithreading android android-asynctask nativescript

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

Nativescript连接文本使用Label

我想在Label中组合字符串.我想要的结果是:3000美元,数据库价格3000.所以我使用代码:

<Label row="2" col="1" text="USD {{ price }}" />
Run Code Online (Sandbox Code Playgroud)

但不工作,并显示如下:

USD {{ price }}
Run Code Online (Sandbox Code Playgroud)

我可以直接连接文本标签中的字符串吗?或任何关于此的线索.不管怎么说,还是要谢谢你

javascript mobile android nativescript

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

如何在 NativeScript 上的 Web 视图中调用 Javascript 函数?

如何在 NativeScript 上的 Web 视图中调用 Javascript 函数(并注册在 Web 视图中的方法执行完成后要执行的回调函数)?

nativescript

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

如何使用Visual Studio模拟器在Windows中运行NativeScript应用程序?

如何使用Visual Studio模拟器在Windows中运行NativeScript应用程序?试图获得这个项目:

https://github.com/avatsaev/nativescript-master-detail-angular2

在Windows 10 64位视觉工作室模拟器中运行,但总是在运行时启动android模拟器:

这是我的adb设备:

List of devices attached
169.254.138.177:5555    device
Run Code Online (Sandbox Code Playgroud)

tns livesync android --emulator --watch

也试过了

tns livesync 169.254.138.177:5555 --emulator --watch

没运气!

问候

肖恩

nativescript

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

Nativescript/angular2:没有applicationRef的提供者!部署后出错

我正在尝试运行一个非常简单的nativescript/angular2应用程序,它似乎构建正常但在应用程序部署到android(genymotion)模拟器后,我收到以下错误消息.所以似乎角度没有自举?不确定为什么这是......任何想法我做错了什么?

错误信息:

"@angular/core": "2.1.2",
"@angular/forms": "2.1.2",
    "@angular/http": "2.1.2",
    "@angular/platform-browseBUILD SUCCESSFUL

Total time: 1 mins 39.836 secs
Project successfully built
Successfully deployed on device with identifier '192.168.8.101:5555'.
JS: ns-renderer: ERROR BOOTSTRAPPING ANGULAR
JS: ns-renderer: No provider for ApplicationRef!
JS:
JS: Error: No provider for ApplicationRef!
JS:     at NoProviderError.Error (native)
JS:     at NoProviderError.BaseError [as constructor] (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:1104:38)
JS:     at NoProviderError.AbstractProviderError [as constructor] (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:1235:20)
JS:     at new NoProviderError (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:1266:20)
JS:     at ReflectiveInjector_._throwOrNull (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2906:23)
JS:     at ReflectiveInjector_._getByKeyDefault (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2934:29)
JS:     at ReflectiveInjector_._getByKey (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2897:29)
JS:     at ReflectiveInjector_.get …
Run Code Online (Sandbox Code Playgroud)

nativescript angular

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

brew cask安装android-sdk

brew cask install android-idk在Mac OS X上安装android sdk()时遇到问题.我尝试将其安装为nativescript.我读过那些遇到同样问题但找不到工作解决方案的人.我试图改变java路径可能会导致问题.

这是我得到的错误:

==> Caveats
We will install android-sdk-tools, platform-tools, and build-tools for you.
You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:
  'export ANDROID_SDK_ROOT=/usr/local/share/android-sdk'

This operation may take up to 10 minutes depending on your internet connection.
Please, be patient.

==> Satisfying dependencies
==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip
Already downloaded: /Users/jhon/Library/Caches/Homebrew/Cask/android-sdk--3859397,26.0.1.zip
==> Verifying checksum for Cask android-sdk
==> Installing Cask android-sdk
==> Warning: Failed to …
Run Code Online (Sandbox Code Playgroud)

homebrew android nativescript angular2-nativescript

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

即使变量已初始化,Angular Nativescript 可见性也默认为 true

有没有办法在 Nativescript 中默认“隐藏”元素?

我的组件中有

export class HouseholdContactComponent{
  private isLoading = true
}
Run Code Online (Sandbox Code Playgroud)

在我的xml中

<StackLayout [visibility]="isLoading ? 'collapse' : 'visible'">
  <Label text="Hi there"></Label>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

使用此代码,屏幕会闪烁“您好”消息,然后消失。

nativescript angular2-nativescript angular

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

如何在 iOS 设备上禁用电子邮件类型的自动大写

我想在 iOS 设备上禁用电子邮件类型的自动大写。这是我的领域:

<TextField hint="Email" class="input input-border" keyboardType="email"></TextField>
Run Code Online (Sandbox Code Playgroud)

当我填充第一个字符时,第一个字符将大写,并且我想防止自动大写。

任何想法?

nativescript

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

无法在 Android 上的 WebView 中下载 Blob 文件类型

我想从 webview 下载文件,但每次都会出错(只能下载 HTTP/HTTPS URI:blob: https://..

我在我的代码中使用这个:

ngOnInit() {
        let webview: WebView = this.webViewRef.nativeElement;

        if (isAndroid) {

            webview.on(WebView.loadStartedEvent, function () {
                webview.android.getSettings().setBuiltInZoomControls(false);
                webview.android.getSettings().setJavaScriptEnabled(true);
                webview.android.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
                webview.android.getSettings().setAllowFileAccess(true);
                webview.android.getSettings().setPluginsEnabled(true);
                webview.android.getSettings().setAllowContentAccess(true);
                webview.android.getSettings().setAllowFileAccess(true);
                webview.android.getSettings().setAllowFileAccessFromFileURLs(true);
                webview.android.getSettings().setAllowUniversalAccessFromFileURLs(true);
                webview.android.getSettings().setDomStorageEnabled(true);
                webview.android.getSettings().setDefaultTextEncodingName("utf-8");

                webview.android.setDownloadListener(new android.webkit.DownloadListener({
                    onDownloadStart(url, userAgent, contentDisposition, mimetype, contentLength) {
                        let request = new android.app.DownloadManager.Request(android.net.Uri.parse(url));
                        request.setMimeType(mimetype);
                        let cookies = android.webkit.CookieManager.getInstance().getCookie(url);
                        request.addRequestHeader("cookie", cookies);
                        request.addRequestHeader("User-Agent", userAgent);
                        request.setDescription("Downloading file...");
                        request.setTitle(android.webkit.URLUtil.guessFileName(url, contentDisposition, mimetype));
                        request.allowScanningByMediaScanner();
                        request.setNotificationVisibility(android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                        request.setDestinationInExternalPublicDir(android.os.Environment.DIRECTORY_DOWNLOADS, android.webkit.URLUtil.guessFileName(url, contentDisposition, mimetype));
                        let dm = utils.ad.getApplicationContext().getSystemService(android.content.Context.DOWNLOAD_SERVICE);
                        dm.enqueue(request);
                    }
                }));
            });
        }
Run Code Online (Sandbox Code Playgroud)

请帮助我。谢谢

android webview angularjs nativescript

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

NativeScript + Angular:如何安装和使用图标?

我正在尝试在适用于 iOS 和 Android 的NativeScript + Angular应用程序上使用图标。我尝试了不同的方式来设置图标,我使用了本教程,这个解决方案,我什至尝试使用材质插件nativescript-ngx-fonticon

所有这些方法都会给我这个错误

插件 nativescript-fontawesome 不包含在设备 [device-id] 上的预览应用程序中,并且无法工作。

现在,这是我当前的代码:

我的组件.组件.html

<Button text="&#xf810" class="fa" column="0"></Button>

应用程序.css

.fa {
    font-family: 'FontAwesome', fontawesome-webfont;
 }
Run Code Online (Sandbox Code Playgroud)

此外,我的app/fonts文件夹中有以下文件:

fontawesome-webfont.ttf

那么,出了什么问题呢?

谢谢

nativescript angular2-nativescript nativescript-angular angular nativescript-plugin

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