如何使用钛合金在控制器中获取选择器值

How to get the picker value in controller using Titanium Alloy?

本文关键字:获取 选择器 控制器 何使用 钛合金      更新时间:2023-09-26

我们如何在控制器中获取选定的picker值并对选定的值进行验证。

视图:

  <Picker id="countryPicker" class="picker">
            <PickerRow title="Select a Country"/>
            <PickerRow title="India"/>
            <PickerRow title="China"/>
  </Picker>

控制器:

var countryname = $countryPicker.value();
alert("country: "+ countryname);
$.planWin.open();

是否在控制器或其他模块中进行了验证?

为选择选择器项时激发的更改事件设置一个事件侦听器。。。

$.countryPicker.addEventListener('change',function(e){
 //do your stuff here 
});

在更改事件中,您可以使用事件对象(e):访问所选项目

e.column, e.rowIndex, ...

有关更多信息和用例,请参阅官方文档。。。