【发布时间】:2016-03-30 09:39:16
【问题描述】:
当我使用Materialize/jQuery 和VueJS 的组合进行选择,然后我尝试选择所需的值时,VueJS 不会更新以反映选择的新值。
我认为这是一个 Materialise 问题;但是,对于 VueJS,我根本无法获得触发更新/更改事件的值。
我所拥有的是下面的 sn-p。我要做的只是让选择 - 或任何选择在由 jQuery 更新时正确更新 VueJS。
这似乎开始变得不可能了,尽管我知道得更多。
$('select').material_select();
$(document).on('change', function(e){
$('#live').text("\n Using JUST jquery... Notice that the vue option remains unchanged\n" + JSON.stringify({ 'selectShouldBe': $(e.target).val()}, null, ' '));
});
new Vue({
el: '.container',
data: {
'select':''
},
methods: {
updateThing: function(){
console.log(this);
}
},
})
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.css">
</head>
<body>
<div class="container">
<!-- here is the select in question -->
<select id='jurisdiction' v-model='select' @change="updateThing">
<option value disabled selected>Please select a value.</option>
<option value='1'>One</option>
<option value='2'>Two</option>
<option value='3'>Three</option>
<option value='4'>Four</option>
</select>
<!-- Print out the data, then pass it through json for easier readability. -->
<pre>
{{$data|json}}
<div id="live"></div>
</pre>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.12/vue.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js">
</script>
</body>
</html>
有什么建议吗?
【问题讨论】:
标签: javascript jquery vue.js materialize