Q-Rating value undefined



  • Hello,

    here I am building one application by using quasar framework.

    I am using Q-Rating component, but it is returning undefined instead the selected value.

    Component inside template

    <q-rating
         v-model="defaultRating"
         size="2em"
         :max="10"
         color="primary"
         @click="clickOnRating" />
    

    Function 'clickOnRating’

    clickOnRating (evt, value) {
          evt.preventDefault()
          console.log(value)  // logs 'undefined'
        }
    

    What am I doing wrong?

    Thank you in advance,
    Stefano



  • @click is a native event and native events only offer the event object, unless otherwise modified by Quasar (see the API). There is no value offered with @click. What you are probably looking for is the @input event. That event gives you only the value. You can also use @click and just take the value of v-model at that point in time too.

    See here for working example: https://codepen.io/smolinari/pen/QWjKjZE

    8c7e59f8-8283-46a9-8b0a-81ec9bc7c7d3-image.png

    Scott



  • I was convinced about using it… too many hours of coding!

    Thank you


Log in to reply