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
                    }
                }

嗯,好了,就到這里了,記錄工作小點滴,讓模棱兩可的事情有處可尋……


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM