当前位置:网站首页>If the amount exceeds 6 digits after the decimal point, only 6 digits will be reserved, and if it is less than 6 digits, it will remain the same - Basic accumulation
If the amount exceeds 6 digits after the decimal point, only 6 digits will be reserved, and if it is less than 6 digits, it will remain the same - Basic accumulation
2022-06-30 00:42:00 【yehaocheng520】
Today's test raised a small requirement : The amount exceeds... After the decimal point 6 When a , Only keep 6 position , Less than 6 Bits remain the same

The structure shown in the figure above , This amount parameter , If there is a decimal point , And more than... After the decimal point 6 digit , Then intercept the first six digits , Otherwise, maintain the original value .
<el-input-number style="width:200px;" v-model.trim="ruleForm.price" @@blur="priceBlur" :min="0" :step="1" size="mini" placeholder=" Single set amount "></el-input-number>
Listen for out of focus events of this component :blur
priceBlur(e) {
var val = e.target.value;
if (val) {
var index = val.indexOf('.');
if (index > -1) {
var arr = val.split('.');
var num = arr[1];
if (num.length > 6) {
this.ruleForm.price = arr[0] + '.' + num.substr(0, 6);
} else {
this.ruleForm.price = val;
}
} else {
this.ruleForm.price = val;
}
}
},
complete !!!
It suddenly occurred to me that when I first came to the company , The director who interviewed me asked me a question like this , My answer at the time was :toFixed(x), Keep as many as you want . Feel this problem , It would be better to use the above method .
边栏推荐
猜你喜欢

数据中台咋就从“小甜甜”变成了“牛夫人”?

Briefly: how are fragments communicated?

Sword finger offer II 037 Asteroid collision

分布式任务调度 ElasticJob demo

网络方向哪个发展更好?数据通信工程师学习路线分享

月薪没到30K的程序员必须要背的面试八股,我先啃为敬!

Interviewer: how to solve the problem of massive requests for data that does not exist in redis, which affects the database?

MySQL高级篇2

Serpentine matrix (array simulates direction, D represents turning)

How much is the fixed asset management system and the price of the fixed asset management system
随机推荐
Is there any discount for securities account opening? Is it safe to open an account online?
Developers, why does the maturity of container technology herald the arrival of cloud native era?
阿洛觉得自己迷茫
MySQL primary key constraint deletion
MySQL advanced 2
@ConfigurationProperties使用不当引发的bug
Modbus TCP RTU protocol chart
Yunna | fixed assets information system management, information-based fixed assets management
[UML] several relationships of UML (dependency Association aggregation composition inheritance Implementation)
降低打新的预期
Yunna | how to use the system to manage fixed assets? How to manage fixed assets?
TwinCAT 3 EL7211模块控制倍福伺服
如何做好测试用例设计
中小企业签署ERP合同时,需要注意这几点
C语言课设心得之“推箱子”课设作品开源分享
MySQL基礎2
字节、字、双字 关系
TwinCAT 3 EL7211模塊控制倍福伺服
Bytek suffered a disastrous defeat in the interview: he was hanged on one side, but fortunately Huawei pushed him in, and he got an offer on three sides
开发者,为什么说容器技术的成熟预示着云原生时代的到来?