Sco*_*ter 9 apache-flex forms binding types
如何将整数绑定到Flex/FB4中的输入字段?is_admin是一个整数:
<s:TextInput id="textUserIsAdmin" text="@{user.is_admin}" width="5"/>
Run Code Online (Sandbox Code Playgroud)
我收到:
1067: Implicit coercion of a value of type String to an unrelated type int.
Run Code Online (Sandbox Code Playgroud)
是否有不同的输入类型,或者我必须以不同的方式绑定?
J_A*_*A_X 16
简短的回答,当你试图改变你绑定的对象的本质时,你不能做2路绑定.它们必须相同或不起作用.话虽如此,有一个解决方法:
<s:TextInput id="textUserIsAdmin" text="{user.is_admin}" restrict="0-9" change="user.is_admin = int(textUserIsAdmin.text)"/>
Run Code Online (Sandbox Code Playgroud)
正如您在此处所看到的,我正在绑定模型中的原始值,但是当用户键入内容时,将调度change事件并传输和保存TextInput值.我还添加了一个'restrict',以便只输入数字.
| 归档时间: |
|
| 查看次数: |
5258 次 |
| 最近记录: |