Vuetify v-select onchange event returns previously selected value instead of current

前端 未结 3 752
Happy的楠姐
Happy的楠姐 2020-12-28 17:40

I have a dropdown that I\'m wanting to use as a list of URLs to navigate to other pages. The issue I\'m running into is the onchange

相关标签:
3条回答
  • 2020-12-28 18:02

    I don't exctly know why ${select.src} is holding previous value on change event. You can give a try with below code:

    <v-select @change="changeRoute" ></v-select>
    
    methods: {
          changeRoute(selectObj) {
            console.log(selectObj)
            console.log(selectObj.src)
         }
    }
    
    0 讨论(0)
  • 2020-12-28 18:09

    I have no idea why change doesn't work properly. But input does work.

    https://codepen.io/jacobgoh101/pen/erBwKa?editors=1011

    v-on:input="changeRoute(`${select.src}`)"
    

    Perhaps you can open a new bug report for Vuetify

    0 讨论(0)
  • 2020-12-28 18:15

    You don't need to specify the data because that's what, I'm guessing, the change event passes by default.

    So change:

    v-on:change="changeRoute(`${select.src}`)"
    

    to just

    v-on:change="changeRoute"
    

    and in the function call:

      changeRoute(a) {
        this.$router.push({path: a.src })
        console.log(a)
      }
    
    0 讨论(0)
提交回复
热议问题