当前位置:网站首页>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 .
边栏推荐
- 阿于的彩虹桥
- Serpentine matrix (array simulates direction, D represents turning)
- 微信支付 APP端 第三弹 申请退款
- Comment personnaliser les modèles et générer rapidement le code complet dans l'idée?
- [MRCTF2020]Ezpop-1|php序列化
- Top performance version 2 reading notes (IV) -- memory monitoring
- 数据库学习笔记(SQL03)
- leetcode-1. Sum of two numbers
- Common settings in idea
- 初始I/O及其基本操作
猜你喜欢

How to create a module in the idea and how to delete a module in the idea?

科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头

Initial i/o and its basic operations

分布式任务调度 ElasticJob demo

面试官:大量请求 Redis 不存在的数据,从而影响数据库,该如何解决?

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

简单的页面
![[daily question 1] traversal of binary tree](/img/e2/313251d574f47708abca308c4c8d5d.png)
[daily question 1] traversal of binary tree
![[cloud native] kernel security in container scenario](/img/cc/828a8f246b28cb02b7efa1bdd8dee4.png)
[cloud native] kernel security in container scenario

Five key elements of the data center
随机推荐
【每日一题】二叉树的前后序遍历
About the case of SQL statements
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
Outsourcing for 3 years is a waste
@Bugs caused by improper use of configurationproperties
Nested call and chained access of functions in handwritten C language
[garment software] what are the criteria for the selection of garment production management system?
Sword finger offer II 035 Minimum time difference
TwinCAT 3 EL7211模塊控制倍福伺服
干外包3年,真废了...
炒股开户选择哪家券商公司比较好哪家平台更安全
TP5 query and and or condition nesting
The third bullet of wechat payment app application for refund
阿于的彩虹桥
【云原生】容器场景下的内核安全
Ml: introduction to confidence interval (the difference and relationship between precision / accuracy / accuracy), use method, and detailed introduction to case application
如何在IDEA中自定義模板、快速生成完整的代碼?
[cloud native] kernel security in container scenario
2022年最新最详细IDEA关联数据库方式、在IDEA中进行数据库的可视化操作(包含图解过程)
DataGridView上移 下移行