标签: nativescript

将JavaScript库导入NativeScript

我正在学习NativeScript。我有一个基本的应用程序正在工作。我现在正在尝试导入过去使用过的JavaScript库。我通过使用以下方式导入库:

npm install git://github.com/my-company/my-project.git --save
Run Code Online (Sandbox Code Playgroud)

我已经确认该软件包已安装。然后在我的视图模型中添加以下内容:

var MyLibrary = require('MyLibrary');
Run Code Online (Sandbox Code Playgroud)

仅此行会导致应用崩溃。基本上,NativeScript似乎无法找到(或加载)它。我看了一下,可以在“ node_modules”目录中看到“ MyLibrary”目录。目录结构如下所示:

.
node_modules
  MyLibrary
    dist
      MyLibrary.min.js
    src
      MyLibrary.js
    package.json
Run Code Online (Sandbox Code Playgroud)

MyLibrary.js文件如下所示:

class MyLibrary {
    process(vals) {        
        let result = 0;
        if (vals) {
            vals.forEach(function(val) {
                result = result + val;
            });
        }
        return result;
    }
}
module.exports = MyLibrary;
Run Code Online (Sandbox Code Playgroud)

“ MyLibrary.min.js”文件是通过Babel运行并将其转换为ES5的结果。我究竟做错了什么?我只是想将以下代码添加到我的视图模型中:

var MyLibrary = require('MyLibrary');
var library = new MyLibrary();
var result = library.process([1, 2, 3, 4]);
Run Code Online (Sandbox Code Playgroud)

javascript node.js nativescript

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

想要本机脚本XML中的textView或textField无底边框

默认文本框具有底部边框。如何在没有底边框的情况下以本机脚本XML获取textView或textField?

nativescript

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

nativescript中的多行文本框

如何在本机脚本中获得支持多行的文本区域?

我尝试使用不支持多行的文本字段.

还试过这段代码在文本字段中添加多行:

var myTextfield = this.page.getViewById<TextField>("noteView");

myTextfield.android.setInputType(android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE);  
Run Code Online (Sandbox Code Playgroud)

nativescript angular

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

Swift Version NativeScript

使用NativeScript如何在iOS下运行项目?我跑的时候收到这些消息tns run iOS --bundle

Webpack compilation complete. Watching for file changes.
Webpack build done!
Copying template files...
Platform ios successfully added. v4.2.0
Executing before-shouldPrepare hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Installing pods...
Analyzing dependencies
Downloading dependencies
Installing Socket.IO-Client-Swift (11.1.3)
Installing StarscreamSocketIO (8.0.7)
Installing Toaster (2.0.4)
[!] Unable to determine Swift version for the following pods:

- `Socket.IO-Client-Swift` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute …
Run Code Online (Sandbox Code Playgroud)

ios cocoapods vue.js swift nativescript

4
推荐指数
3
解决办法
4625
查看次数

AndroidX突然导致NativeScript的构建失败

突然之间,我的依存关系没有变化,现在出现以下错误:

Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:18:2-31:16 to override.
Run Code Online (Sandbox Code Playgroud)

我已经尝试应用建议(以及相关的命名空间XML属性),但不幸的是,这会产生一条消息,类似multiple errors, see logs,但我不知道日志在哪里。

我已经阅读并阅读了此书,并且我理解尝试同时拥有AndroidX和现已弃用的支持库是一个问题。但是,在此突然停止构建之前,我没有更改任何依赖关系-仅清除了平台以强制进行完全重建。

我不知道哪个插件有冲突,而且我也知道Jetifier应该对此进行补救,除了NativeScript似乎不让我能够以gradle.properties任何持久的方式(我知道)进行修改,并且当前没有使用NativeScript的最新版本(这是令人困惑,因为NativeScript5.4.1TNS核心模块5.4.2在我加入这个平台package.json似乎是5.4.0)似乎不使用Jetifier和NPM最新AndroidX构建似乎有点过时了。

那么,如何才能立即恢复我的应用程序并使其运行呢?救命!

android nativescript

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

Nativescript获取当前页面

如何获得我正在处理的当前屏幕?例如,我有一个包含按钮的slidedrawer,可以导航到另一个页面.当我在某个页面(关于页面)上,当我点击按钮导航到关于页面时,我想关闭slidedrawer,如果它在同一页面上.

我的想法是获取当前页面并进行比较,但我不知道如何.

注意:slidedrawer内容菜单是一个自定义组件.

nativescript

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

NativeScript:如何将iOS应用程序部署到物理设备?

我在Telerik创建了一个帐户,与Apple Dev Center签署了一个证书并获得了移动配置.我使用Appbuilder将证书和配置导入我的笔记本电脑.但我还是无法在iOS上部署我的应用程序

tns deploy ios
Run Code Online (Sandbox Code Playgroud)

警告说:

重要信息:在构建iOS设备之前,请确认您已在OS X系统上配置了一对有效的证书和配置文件.

但是,当我执行"appbuilder provision"和"appbuilder certificate"时,命令显示我们已成功导入它们.我也尝试过:

appbuilder deploy ios --provision '<name>' --certificate '<title>'
Run Code Online (Sandbox Code Playgroud)

它说没有在路径上或路径上找到任何项目,也没有指定--path.但我在项目文件夹中.:/

ios telerik-appbuilder nativescript

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

图像按钮Nativescript和Angular

我需要创建一个图像按钮,其中包含自定义图像和{N} + Angular中的标签.像这样的东西:

在此输入图像描述

这是我的代码.我正在使用网格布局中的堆栈布局.我看不到图像下方的标签.

<GridLayout columns="*,*" rows="*,*,*,*,*,*"  width="400" height="400">
    <StackLayout class="  btn-sq-lg  " col="0" row="0" (tap)="gotoSRTPage()">
        <Image  col="0" row ="1" src="res://ic_briefcase" > </Image>
        <Label class= "label" textWrap="true" col="0" row="2" text="SRT" horizontalAlignment="center" verticalAlignment="center"></Label>
    </StackLayout>  
    <StackLayout class="  btn-sq-lg  " col="1" row="0" (tap)="">
        <Image  col="1" row ="1" src="res://ic_blog" > </Image>
        <Label  class= "label" col="1" row="2" text="SRT" horizontalAlignment="center" verticalAlignment="center"</Label>
        </StackLayout>    
         <StackLayout class="  btn-sq-lg  " col="0" row="3" (tap)="">
        <Image  col="0" row ="4" src="res://ic_reminder" > </Image>
        <Label class= "label" textWrap="true" col="0" row="5" text="SRT" horizontalAlignment="center" verticalAlignment="center"></Label>
        </StackLayout> …
Run Code Online (Sandbox Code Playgroud)

nativescript angular2-nativescript nativescript-telerik-ui

3
推荐指数
2
解决办法
7659
查看次数

如何在单击angular2本机脚本时打开按钮上的playstore应用程序URL

单击按钮时,我需要在playstore应用程序的帮助下打开playstore应用程序URL。我有来自Playstore的许多应用程序网址。

例如: https //play.google.com/store/apps/details?id = com.ninjakiwi.bftg

应用程序不应在浏览器的帮助下打开。单击按钮时,它必须在官方google playstore应用程序的帮助下打开。

typescript nativescript angular2-nativescript angular

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

Nativescript 6非常慢

我们的应用程序是使用nativescript 4开发的。AndroidStore级别的规则更改迫使我们进入了nativescript6。因为我们的应用程序非常慢。例如,密码输入有时会冻结,在菜单中选择时会有延迟。是否有人遇到相同的问题,并且有解决方案来提高应用程序的响应能力?

ps:我们已经使用了以下编译选项:-env.aot --env.snapshot --env.uglify --production

先感谢您

performance nativescript angular

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