<template>
<el-input v-model="stepPrice" @blur="checkStepPrice()"/>
</template>
<script>
export default {
data() {
return {
stepPrice:""
reiceNum:"" //精度,从后端接口获取
}
}
methods:{
checkStepPrice(){
let str=''
if(stepPrice.indexOf('.')!=1){
str=stepPrice.split('.')[1]
if(str.length>reiceNum){
this.$vMessage({
type: 'warning',
message: '请保留' + this.reiceNum + '小数',
duration:vm.messageTime
})
}
}
}
}
</script>
vue根据后端返回的字段,判断小数精度
于 2022-12-06 15:53:40 首次发布