1
How can I perform the following procedure to update data from a directive in Vue.
var select = Vue.directive('select', {
twoWay: true,
bind: function(el, binding, vnode){
// Como acessar op ?????
// this.set()
}
})
new Vue({
el: '#demo',
data: function(){
return {
op: 2
}
}
});
select{
width:200px;
padding:5px;
}
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="demo">
<p>Opção: {{ op }}</p>
<select v-select>
<option v-bind:value="1">1</option>
<option v-bind:value="2">2</option>
</select>
</div>
@Jjay did not understand very well the purpose of its implementation. What do you want to achieve? Why not use a v-model to update the data?
– Nocttuam
I am using Materialize in a project, and some resources use jQuery, in this case, in the select field would use the method . change() from jQuery to intercept and then update the model value and enforce the Vue scope.
– JJJay