Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify v-text-field change value

how can i manipulate input value. Show hier is example

`https://jsfiddle.net/mbqjp4ax/`

if number greater than 5, number 9 should be entered. if I enter more than 5 it works fine but if I keep typing it will not work as expected.

like image 644
Vin Avatar asked Nov 29 '22 08:11

Vin


1 Answers

You dont need to use getElementsByTagName and such things in vue. And $refs have a limited usage too. You should just use v-model.

Here your fiddle fixed

https://jsfiddle.net/pm9zwesr/

<v-text-field
    label="Price"
    v-model="price"
    @input="up">
</v-text-field>

new Vue({
  el: '#app',
  data () {
    return {
      price: 123.45
    }
  },
  methods: {
    up (){
      if (parseFloat(this.price) > 5) {
        this.$nextTick(() => {
          this.price = 9
        })        
      }
    },

    reset () {
      this.price = 0
    }
  }
})
like image 56
Aldarund Avatar answered Dec 04 '22 06:12

Aldarund