标签: nativescript

Nativescript-Angular - 从服务运行回调时 UI 不会更新

我有一个本地脚本角度应用程序,它运行蓝牙服务来连接到外围设备(设备)。该应用程序会显示一个标签,其中包含一条消息,指示尚未将蓝牙设备连接到运行该应用程序的移动设备。我想做的是更新 UI,以便标签在发生连接时消失(并在发生断开连接时重新出现)。

应用程序组件.tns.html

<StackLayout orientation="vertical" marginBottom="50">
  <Label text="No bluetooth device detected." id="noBluetoothWarning" horizontalAlignment="center" color="#B11" *ngIf="bluetoothDisconnected" marginTop="30" visibility="{{ isBluetoothConnected ? 'collapsed' : 'visible' }}"></Label>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

应用程序组件.ts

export class NSAppComponent extends AppComponent implements OnInit {


  pageData: Observable;

  ngOnInit() {
    this.bluetoothDisconnected = true;

    let _page = <Page>topmost().currentPage;
    _page.actionBarHidden = true;
    _page.frame.bindingContext = this.pageData;

    let that = this;

    this.bluetoothScanner.connectionStateChangeEvent.subscribe((connectionState) => {
      that.log.debug(`Am I in an angular zone? ${NgZone.isInAngularZone()}`);
      this.ngZone.run(() => {

        that.log.debug(`connectionStateEvent triggered! state is: ${connectionState}`);

        that.bluetoothDisconnected = !connectionState;

        that.pageData.set("isBluetoothConnected", connectionState);

        that.pageData.notify({ object: that.pageData, …
Run Code Online (Sandbox Code Playgroud)

zone nativescript angular2-nativescript angular

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

模态页面上 NativeScript 中 ScrollView 的粘性页眉和页脚

有没有办法在模态页面上实现带有粘性页眉和页脚的滚动视图。像这样的粘性页眉/页脚,中间有 ScrollView

这是我已经准备好的,但是包含社交按钮的 GridLayout 被截断了。

<Page xmlns="http://schemas.nativescript.org/tns.xsd" shownModally="onShownModally" class="test">
  <StackLayout orietation= "veritcal" class="mainstack">
    <GridLayout rows="auto" columns="*, auto">
      <label text="{{title}}" textWrap="true" class="size16b align-center" col="0" row="0" />
      <Button text="&#xE5CD;" horizontalAlignment="right" tap="closePage" class="btn" col="1" row ="0"/>
    </GridLayout>
    <ScrollView>
      <ios><HtmlView class="stack" html="{{htmlString}}" /></ios>
      <android><WebView class="stack" src="{{htmlString}}" id="andWebView"/> </android>
    </ScrollView>
    <GridLayout rows="auto" columns="*, *, *, *" class="gridLay">
        <Button text="&#xf099;" horizontalAlignment="center" tap="closePage" class="socialbtn" col="0"/>
        <Button text="&#xf230;" horizontalAlignment="center" tap="closePage" class="socialbtn" col="1"/>
        <Button text="&#xf16d;" horizontalAlignment="center" tap="closePage" class="socialbtn" col="2"/>
        <Button text="&#xf166;" horizontalAlignment="center" tap="closePage" class="socialbtn" col="3"/>
    </GridLayout>
  </StackLayout>
</Page> …
Run Code Online (Sandbox Code Playgroud)

nativescript

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

重命名 NativeScript iOS 应用程序

我需要重命名我的应用程序,但我不确定从哪里开始。我尝试手动更改一些文件夹/文件的名称,但一切都失败了,我想是因为使用原始名称的事情比我预期的要多。我查看了以下帖子,但不幸的是,它适用于 Android(我正在构建一个 iOS 应用程序)。重命名应用程序名称

ios nativescript

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

NS 中的六边形图像视图

我怎样才能创建一个像 NS 这样的组件?

如何给 ImageView 赋予六边形形状

我想创建一个具有六边形外观的图像组件,但我无法弄清楚如何正确扩展 nativescript 类以获得此结果。

android image nativescript

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

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

本机脚本获取和显示

我需要使用 nativescript 的最简单的获取和显示示例。如果有人有一些 github 存储库,我将不胜感激。谢谢 实际上,我想读取一个 JSON 并在本机脚本的列表中显示数据。

fetch nativescript

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

如何将自定义nativescript-Vue组件传递给自定义子组件

我想使用 Nativescript-Vue 将动态子组件添加到父组件。例如:

<template>
    <MyParentComponent>
        <MyChildComponent :foo="foo"></MyChildComponent>
    </MyParentComponent>
<template>

<script>
    import MyParentComponent from './components/MyParentComponent';
    import MyChildComponent from './components/MyChildComponent';

    export default {
        components: {
            MyParentComponent,
            MyChildComponent
        },
        data: function(){
            return {
                foo: ''
            }
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

我想我需要在父组件中定义一个插槽,在其中插入子组件,但我不知道应该如何完成。

有任何想法吗?

nativescript nativescript-vue

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

NativeScript 安装时缺少写入访问错误

当我尝试通过运行安装 nativescriptt 时npm i -g nativescript,收到以下错误:

    npm WARN checkPermissions Missing write access to 
    /usr/local/lib/node_modules/nativescript
    npm ERR! path /usr/local/lib/node_modules/nativescript
    npm ERR! code ENOENT
    npm ERR! errno -2
    npm ERR! syscall access
    npm ERR! enoent ENOENT: no such file or directory, access 
    '/usr/local/lib/node_modules/nativescript'
    npm ERR! enoent This is related to npm not being able to find a 
    file.
Run Code Online (Sandbox Code Playgroud)

我尝试以 sudo 身份运行该命令并收到相同的结果。我还尝试向该node_modules目录添加写权限。

我在 macOS High Sierra 上运行节点 v10.6.0。

npm node-modules nativescript

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

运行`tns build android`时出现错误`spawn ./gradlew ENOENT`

我从 nativescript 开始。我正在尝试构建一个 hello world 应用程序来测试它。但是,当我运行它时,我得到一个退出状态 127 for command not found。

这是我尝试构建的方法:

[ahmed@localhost hello]$ tns build android
Executing before-shouldPrepare hook from /home/ahmed/PycharmProjects/hello/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Skipping prepare.
Building project...
Gradle build...
spawn ./gradlew ENOENT
[ahmed@localhost hello]$ echo $?
127
[ahmed@localhost hello]$ 
Run Code Online (Sandbox Code Playgroud)

如果我跑tns doctor,一切似乎都好

[ahmed@localhost hello]$ tns doctor
? Getting environment information 

No issues were detected.
? Your ANDROID_HOME environment variable is set and points to correct directory.
? Your adb from the Android SDK is correctly installed.
? The Android SDK …
Run Code Online (Sandbox Code Playgroud)

nativescript

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

NativeScript Angular 错误 TS5060:如果不指定“--baseUrl”选项,则无法使用选项“paths”

我使用以下命令新安装了 Nativescript Angular 项目:

\n
ng new --collection=@nativescript/schematics my-mobile-app\n
Run Code Online (Sandbox Code Playgroud)\n

我从nativescript-schematics获得的命令

\n

全新安装后,我尝试在 Android 模拟器上运行它。

\n
tns run android\n
Run Code Online (Sandbox Code Playgroud)\n

然后我在编译过程中收到此错误:

\n
Searching for devices...\nPreparing project...\nFile change detected. Starting incremental webpack compilation...\n\nwebpack is watching the files\xe2\x80\xa6\n\nHash: c018afa003f9a5a7d1cd\nVersion: webpack 4.44.2\nTime: 4451ms\nBuilt at: 11/05/2020 1:54:33 PM\n 3 assets\nEntrypoint bundle = runtime.js vendor.js bundle.js\n[./app.css] 1.05 KiB {bundle} [built]\n[./main.ts] 1.13 KiB {bundle} [built]\n[~/package.json] external "~/package.json" 42 bytes {bundle} [optional] [built]\n    + 331 hidden modules\n\nERROR in error TS5060: Option \'paths\' cannot be used without …
Run Code Online (Sandbox Code Playgroud)

webpack nativescript angular2-nativescript nativescript-angular angular

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

如何使用 Nativescript 获得手机的电源寿命?

我尝试使用这样的 nativescript 但它不起作用:

battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery || navigator.msBattery;

console.log("battery level: ", Math.floor(this.battery.level * 100) + "%");
Run Code Online (Sandbox Code Playgroud)

nativescript

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

使用 Vue JS 构建原生应用

我是 javascript 新手,特别是 vue js。我找到了 3 个“框架” cmiiw来使用 vue.js 构建本机应用程序。1. Native Script (使用 vue.js) -> https://www.nativescript.org 2. Vue Native -> https://vue-native.io/ 3. NativeScript-Vue -> https://nativescript- vue.org/

您对这三个“框架”有何看法?哪一个最适合构建本机应用程序。

javascript vue.js nativescript vuejs2

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

有一个很好的VueJs原生移动平台吗?

所以我想使用Vuejs构建一个小型原生移动应用程序.我知道有两个平台可以使用VueJs开发本机移动应用程序; Weex和Nativescript.这是我的问题:

1-您是否使用过任何平台?如果是的话,它们有什么好处吗?(到目前为止,我听到了不好的评论)

2 - 根据我的研究,React Native比两个平台都要好,所以我很高兴知道这里是否有人使用' Vuejs to ReactJs converter '?React-Vue:https://github.com/SmallComfort/react-vue

3-我应该放弃我的VueJs背景并去Reactjs和React Native吗?

谢谢

web-deployment angularjs nativescript mobile-development weex

-13
推荐指数
2
解决办法
410
查看次数