VUE 之 让数字四舍五入

时间:2019-09-29 16:32:08   收藏:0   阅读:560

一、在template标签中增加 :

                <template>
                    ……
                   <el-table-column label="检索匹配分值" prop="score">
                      <template slot-scope="scope">{{scope.row.score | formatPrice}}</template>
                    </el-table-column>
                    ……
                </template>

二、 在script标签中增加:

                filters: {
                    formatPrice: function (value) {
                        let tempVal = parseFloat(value).toFixed(3)
                        let realVal = tempVal.substring(0, tempVal.length - 1)
                        return realVal
                    }
                }

嗯,好了,就这里了,记录工作小点滴,让模棱两可的事情有处可寻……

原文:https://www.cnblogs.com/zongheng14/p/11607679.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!