我正在尝试使用bootstrap touchspin
+ numeraljs
将我的货币输入的位置设置为pt-br
。
为此,我通过NumeralJS
注册了一个自定义语言环境,因此当我使用创建 increment 和 decrement 功能的语言环境时,它们无法正常工作。如果我使用区域设置en
,则这些功能可以正常运行。
使用的javascript
代码如下:
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
define(['../numeral'], factory);
} else if (typeof module === 'object' && module.exports) {
factory(require('../numeral'));
} else {
factory(global.numeral);
}
}(this, function(numeral) {
numeral.register('locale', 'pt-br', {
delimiters: {
thousands: '.',
decimal: ','
},
abbreviations: {
thousand: 'mil',
million: 'milhões',
billion: 'b',
trillion: 't'
},
ordinal: function(number) {
return 'º';
},
currency: {
symbol: 'R$'
}
});
}));
numeral.locale('pt-br');
$("input[name='demo_callback']").TouchSpin({
callback_before_calculation: function(v) {
return numeral(v).value();
},
callback_after_calculation: function(v) {
return numeral(v).format("$0,0.00");
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-touchspin/4.2.5/jquery.bootstrap-touchspin.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<input id="demo_callback" type="text" value="1.00" data-bts-min="-1" data-bts-max="1000000" data-bts-step=".01" data-bts-decimals="2" name="demo_callback" />
最诚挚的问候
答案 0 :(得分:0)
感谢所有尝试提供帮助的人,
我能够通过将语言环境System.out.println(countingConsumer.count);
的小数分隔符替换为语言环境int count = 0;
for(String s : names){
if(s.length() > 6){
count++;
}
}
的十进制分隔符来解决该问题,然后通过{ {1}}:
en
pt-br