vuetify v-slider Cannot get new position after click on slider

时间秒杀一切 提交于 2021-01-29 05:13:46

问题


In my AudioPlayer component, I have a v-slider I cannot get the value after cha,ging the slide position ;-)

      <v-slider @change="setPosition()" :value="trackProgress" :v-model="percentage" thumb-label></v-slider>


    data() {
      return {
        percentage: 0
      };
    },
    computed: {
        trackProgress: function() {
          return this.progress * 100;
        }
      },
    methods: {
        setPosition() {
          console.log("SET POSITION: ", this.percentage); // always 0 !!!
          // this.setProgress(this.percentage / 100);
          // this.togglePlayback();
        }
    }, 

回答1:


You're using : on the v-model-attribute, which lets Vue think it's a binded prop with the name "v-model", rather than the v-model itself.

Replace :v-model with v-model:

<v-slider @change="setPosition()" :value="trackProgress" :v-model="percentage" thumb-label></v-slider>

should be

<v-slider @change="setPosition()" :value="trackProgress" v-model="percentage" thumb-label></v-slider>


来源:https://stackoverflow.com/questions/52370173/vuetify-v-slider-cannot-get-new-position-after-click-on-slider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!