[Bug Report] Decimal separator format in el-input-number

fergardi
创建于
2018-03-01 13:10:27

Element UI version

2.2.0

OS/Browsers version

Chrome Version 64.0.3282.186

Vue version

2.5.13

Reproduction Link

https://jsfiddle.net/mmx38qxw/393/

Steps to reproduce

Introduce "2,23" with a comma instead of a dot.

What is Expected?

Format the number with decimals correctly either using separator "," or "." for internationalization purposes. Or add a new prop for stablishing the decimal separator character.

What is actually happening?

The new number is not valid and dissapears if the decimal separator is not ",".

14条回答
wacky6
回复于
2018-03-01 15:10:50
#1

Also see: #8515

Need elaboration on behavior:

  • should the component consider both separator to be valid?
  • how to determine which one is decimal point in mixed input, eg: 10,000.30 vs 10.000,30
  • what if user inputs 1,3 where locale says decimal point is .
  • consider vue-i18n / native Intl ?

How to test i18n related stuff in tests? (Also daylight saving time, see date-picker's test)

fergardi
回复于
2018-03-06 12:30:47
#2

Thanks for your reply.

  • In my opinion, the thousands separator on a form float input is useless, it's only valid for readability purposes (due to database persistency behaviour).
  • The decimal separator could be passed as a prop and used after in the regexp for formatting.
  • If the decimal separator is switched, then a simple string replace should occur to the valid one, thus giving the user a visual hint of what is happening by the way, not needing any more visual aid.
  • My idea is to use the i18n key in order to pass the needed character, as I'm actually doing for the ElDatePicker component "format" prop.

I believe those changes will not take too long and will improve que i18n of the component.

wacky6
回复于
2018-03-06 13:57:48
#3
Leopoldthecoder
回复于
2018-03-11 12:06:44
#4

I'm inclined to adding a prop decimal-separator which defaults to '.'. i18n may not be a good place to put such a key, as in most cases the decimal separator is the same among different languages.

fergardi
回复于
2018-03-15 11:11:49
#5

That would be awesome.

fergardi
回复于
2018-04-10 13:57:22
#6

Any news on this one? I'm looking forward this feature.

jaime-marcondes
回复于
2018-06-11 21:20:47
#7

There any news on this ? Thanks!

fergardi
回复于
2018-08-02 07:51:25
#8

No advances in 5 months? This makes me sad :(

cuivip
回复于
2018-08-14 12:23:16
#9
jiankafei
回复于
2019-03-25 03:02:04
#10

现在的 el-input-number 感觉可有可无,完全没有起到这个组件的作用楼上那个真的可以借鉴下

当前位于第1页,总计14 条回复

推荐相似问题

[Feature Request] Inline datepicker

Existing Component Yes Component Name Datepicker Description Inline display datepicker like https://jqueryui.com/datepic
讨论数 3
element
创建时间:2018-03-01 10:00:02

el-menu open方法

使用el-menu的open方法 不刷新页面没有错误 刷新页面报错
讨论数 2
element
创建时间:2018-03-01 06:58:01

checkbox 更新绑定的组数时,原先v-model绑定为true 的被保留了下来,没有进行刷新。。

checkbox 更新绑定的组数时,原先v-model绑定为true 的被保留了下来,没有进行刷新。。
讨论数 2
element
创建时间:2018-03-01 03:34:17

autocomplete放在表单中每次清空之后,在重新输入模糊匹配的效果往往会失效

http://element.eleme.io/#/zh-CN/component/input autocomplete放在表单中每次清空之后,在第二次之后的输入中模糊匹配的效果往往会失效,或者说是非常卡慢,半天不出现模糊匹配的提示。没有任
讨论数 3
element
创建时间:2018-03-01 03:28:20

[Feature Request] Give mutiple choice in Cascader component

Existing Component Yes Component Name Cascader Description In the Cascader component , we can only select one value now
讨论数 2
element
创建时间:2018-03-01 03:12:39

[Feature Request] Give mutiple choice in Cascader component

Existing Component Yes Component Name Cascader Description In the Cascader component , we can only select one value now
讨论数 2
element
创建时间:2018-03-01 03:07:31

[Bug Report] [Bug Report] el-input-number is unusual in press button

Element UI version 2.2.0 OS/Browsers version Chrome version 64.0.3282.186 Vue version 2.5.13 Reproduction Link https://j
讨论数 8
element
创建时间:2018-03-01 02:25:03

[Bug Report] el-input-number is unusual in press button

Element UI version 2.1.0 OS/Browsers version Chrome version 64.0.3282.186 Reproduction Link http://element-cn.eleme.io/#
讨论数 2
element
创建时间:2018-03-01 02:16:29

[Bug Report] el-input-number not listening 'input' event

Element UI version 2.1.0 OS/Browsers version Vue version 2.5.13 Reproduction Link https://jsfiddle.net/Lvhcwuo3/1/ Steps
讨论数 4
element
创建时间:2018-03-01 01:36:05

Feature Request: Slide Out Panel

Need a slideout panel which can slide from all the side
讨论数 2
element
创建时间:2018-03-01 00:34:26