html:
<div class="form-group">
<label class="col-md-2 control-label">项目领域</label>
<div class="col-md-5">
<label class="checkbox-inline" v-for="obj in industryBelongss">
<input type="checkbox" :value="obj.id" v-model="project.industryBelongs[$index].id" name="checkPro" >
<span class="choice checkbox-theme">{{obj.name}} {{$index}}</span>
</label>
</div>
</div>
js代码:
vmInit: function () {
this.constant.PROJECT = new Vue({
el: "#releaseProject",
data: {project:{provinceCode:null,provinceName:null,cityCode:null,cityName:null,countyCode:null,countyName:null,investStage:[],industryBelongs:[]},investStages:[],industryBelongss:[]},
methods: {
releaseProjectSubmit: function () {
//$.post(releaseProjectObj.constant.SAVE_PROJECT_URL, {policyRegion: releaseProjectObj.constant.PROJECT.policyRegion},
// function (retData) {
// layer.msg(retData.header.retMsg);
// if (retData.header.retCode == "000000") {
// location.href = releaseProjectObj.constant.PROJECT_LIST_URL;
// }
// }, 'json');
},
/* selectName:function(index,val){
console.log($("input[name='checkPro']").val())
}*/
}
});
},
效果:
项目领域教育 0 金融 1 汽车交通 2 房产服务 3 医疗健康 4 旅游 5 本地生活 6 游戏 7 广告营销 8
industryBelongs": [
{
"id": true
},
{
"id": true
},
{
"id": true
},
{
"id": true
}
],
这里我想取的是id的值 为什么选中checkbox 绑定的是true?
改成这样应该就行
vue checkbox