更新时的Nativescript日志滑块值 [英] Nativescript log slider value on update

查看:75
本文介绍了更新时的Nativescript日志滑块值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Nativescript的新手。昨天我问如何创建滑块并读取这些值。这个问题得到了回答,但是现在我想在滑块的值更新后记录这些值。

I am new to Nativescript. Yesterday I asked how to create a slider and read those values. This question was answered however now I want to log those values once the value of the slider has been updated.

我做了一个示例项目,一旦按下一个值就打印出值按钮。现在我想在每次滑块的值更改时打印该值。我查看了滑块文档 propertyChange event 文档,但无法使其正常工作。

I made a sample project that prints the value once I press a button. Now I want to print the value each time the value of the slider changes. I looked at the slider documentation and the propertyChange event documentation but can't get this to work.

以下是我在尝试此操场的链接:游乐场

Here is the link to the playground I am trying this in: Playground

任何人都可以告诉我如何将我的滑块正确绑定到observable以及我如何捕获一旦触发的事件价值更新?

Can anybody tell me how I'd properly bind my slider to the observable and how I'd capture the event that fires once the value updates?

提前致谢!

推荐答案

你可以附上通过代码隐藏到 valueChange 监听器。

You could attach to the valueChange listener via code-behind.

exports.onSliderLoaded = function (args) {
  const slider = args.object;

  slider.on("valueChange", (args) => { 
    console.log(args.value);
  })
}

其中 onSliderLoaded 通过已加载滑块事件

<Slider value="{{ slider }}" loaded="onSliderLoaded" />

可以找到演示以上内容的完整游乐场演示这里

Full Playground demo demonstrating the above can be found here

这篇关于更新时的Nativescript日志滑块值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆