VUE 之让数字四舍五入

一、在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
                    }
                }

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