optimize the inputNumber

fixed bug
1. when setting the precision, inputNumer cannot input '.' bug
2. when setting  the precision, the cursor positoning bug
This commit is contained in:
mo.duan 2019-09-02 12:07:10 +08:00
parent 6daad53fdf
commit 5ece780d09
2 changed files with 26 additions and 4 deletions

View file

@ -72,6 +72,9 @@
:formatter="value => `${value}%`"
:parser="value => value.replace('%', '')"></InputNumber>
</div>
<div style="margin-top: 10px">
<InputNumber v-model="value4" style="width: 200px" :precision='2' ></InputNumber>
</div>
</div>
</template>
<script>
@ -81,6 +84,7 @@
value1: 1800000,
value2: 55,
value3: 100,
value4 : null,
valueNull:null,
formatter: (value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ','),
parser: (value) => value.replace(/\$\s?|(,*)/g, ''),