0
对不起我的英语......不是很好,但我会尽力解释我的问题。我得到一个表单,其中有一些输入字段必须以货币格式显示值,但字段的属性“值”必须是float类型的。恢复:我希望输入以货币格式显示他的价值,但要改变他的浮动价值。 我正在使用Knockout来完成值的绑定。 我上面的尝试之一: HTML代码:更改属性文本并保留输入值与淘汰赛
<input data-bind="value: unit_price, attr:{text: $parent.currency($data.unit_price())}" type="text" name="unit_price" class="align_right unit_price_col" />
淘汰赛:
self.currency = ko.computed({
read: function(key) {
},
write: function(value) {
console.log(value); // Value of the input
}
});
我的尝试是试图创建一个计算的功能,当值被改变,该函数接收值,格式该值为货币,只更改属性文本以显示格式化值,而不更改observable的值。 这可能吗?
谢谢