el-input 输入值大于0且最多保留两位小数

 1.

  <el-input v-model="value"
              onkeyup="value=value.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/,'$1')" 
            />

2.

   <el-table-column prop="price" label="价格">
          <template scope="scope">
            <el-input v-model="scope.row.price" @input="changePrice(scope.row)" />
          </template>
   </el-table-column>  

   changePrice(row) {
      row.price= row.price.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/,"$1");
   },

d{0,2} 代表保留两位小数 

猜你喜欢

转载自blog.csdn.net/future_1_/article/details/130089155