【发布时间】:2018-02-18 19:00:09
【问题描述】:
有一个很好的examples of integrating vue with select2。
我有一个问题。
如果我们看这部分代码:
mounted: function () {
var vm = this
$(this.$el)
// init select2
.select2({ data: this.options })
.val(this.value)
.trigger('change')
// emit event on change.
.on('change', function () {
vm.$emit('input', this.value)
})
}
我不明白,为什么当我们改变 select2 的值时,this.value 也会改变。 我期待这样的记录:
.on('change', function () {
this.value = $(this.$el).val()
vm.$emit('input', this.value)
})
【问题讨论】:
标签: vue.js