简体   繁体   English

Aurelia Value Converter越野车行为与百分比

[英]Aurelia Value Converter Buggy Behavior with percentage

I am trying to convert a user input to a percentage using aurelia converter and Numeral.js . 我正在尝试使用Numeral.js aurelia converterNumeral.js将用户输入转换为百分比。

Here is the gist: https://gist.run/?id=5bbfa902b1d14bff6f506dfcf2045370 这是要点: https : //gist.run/? id =5bbfa902b1d14bff6f506dfcf2045370

The conversion is buggy. 转换是越野车。 Basically, when I am entering the number, it does not behave as expected. 基本上,当我输入数字时,它的行为不符合预期。 Sometimes, I am not able to enter the value, and sometimes it just enters wrong value. 有时,我无法输入值,有时则输入了错误的值。 The behavior is random. 该行为是随机的。

I am not sure if the error is caused by value converter trying to convert the number at the same time I am typing. 我不确定该错误是否是由于value converter试图在我键入的同时转换数字而引起的。 Is there a workaround? 有解决方法吗?

It's trying to update on every key stroke. 它正在尝试更新每个按键。 You want it to update after leaving the input. 您希望它在保留输入后进行更新。 Try using value.bind="score | numberFormat & updateTrigger:'blur'" instead. 尝试使用value.bind="score | numberFormat & updateTrigger:'blur'"代替。

You can learn more about binding behaviors in the Aurelia docs . 您可以在Aurelia文档中了解有关绑定行为的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM