【发布时间】:2017-04-13 14:41:21
【问题描述】:
当 iCheck 框在没有 VueJS 绑定的情况下正常工作时,我遇到了一个奇怪的情况。但是,当我选中一个框时,它根本没有链接到 Vue。
HTML 代码:
<div class="box box-success box-solid" id="root">
<div class="box-header with-border">
<h3 class="box-title">Health</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
</div>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<div class="box-body" style="display: block;">
<div class="form-group col-md-12">
<input type="checkbox" id="green" value="Green" v-model="checkedHealths">
<label for="green">Green</label>
</div>
<div class="form-group col-md-12">
<input type="checkbox" id="red" value="Red" v-model="checkedHealths">
<label for="red">Red</label>
</div>
<div class="form-group col-md-12">
<input type="checkbox" id="yellow" value="Yellow" v-model="checkedHealths">
<label for="yellow">Yellow</label>
</div>
</div>
<!-- /.box-body -->
<pre>{{$data | json}}</pre>
</div>
JS代码:
new Vue ({
el: "#root",
data: {
checkedHealths: ['Green']
},
mounted: function(){
jQuery('input').iCheck({
checkboxClass: 'icheckbox_square-green',
radioClass: 'iradio_square-green',
increaseArea: '20%' // optional
});
}
})
我可以使用该复选框,并且似乎它没有触发可以捕获新值的事件。
您可以查看我的示例代码:http://codepen.io/techcater/pen/mmdLOX
谢谢,
【问题讨论】:
-
嗨@RoyJ。感谢您展示这一点。我尝试使用组件。但是,在输入上调用自定义事件时我仍然遇到问题。你能帮忙看看我的代码吗:jsfiddle.net/dalenguyen/y3jadwpd/30
标签: javascript vue.js icheck