在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ element ui slider滑塊賦值無效

element ui slider滑塊賦值無效

<el-slider v-model="volume"></el-slider>
var app = new Vue({
    el: '#app',
    data: {
        volume: 50,
    },
    created: function() {
        this.getVolume();
    },
    methods: {
        getVolume: function() {
            axios.get(url).then(function(response) {
                this.volume = response.data.volume;
                console.log(this.volume) // 這里能夠打印出來
            }).catch(function(err) {
                console.log(err);
            });
        }
    }
})

console面板能夠打印出數(shù)值,說明this.volumey已經(jīng)被賦值了,但是html里面的slider插件一直顯示初始化的50,并沒有將獲取到的值重新加載,希望有人能解惑,謝謝

回答
編輯回答
若相惜

這個this不是vue實例吧,這樣寫試試。

var app = new Vue({
    el: '#app',
    data: {
        volume: 50,
    },
    created: function() {
        this.getVolume();
    },
    methods: {
        getVolume: function() {
            const that = this;
            axios.get(url).then(function(response) {
                that.volume = response.data.volume;
                console.log(that.volume) // 這里能夠打印出來
            }).catch(function(err) {
                console.log(err);
            });
        }
    }
})
2018年1月15日 12:11