Open luxueyan opened 8 years ago
Can you share the reproduction codes please?
This is my template & data model
<div v-if="field.type === 'checkboxs'">
<div class="clfix mt-40">
<div class="checkbox-label" v-for="cb in field.options">
<input autocomplete="off" v-model="filter[field.key]" :id="field.key + '_' + cb.key" :value="cb.value" :field="field.key" v-validate="field.validate" type="checkbox">
<label :for="field.key + '_' + cb.key">{{cb.value}}</label>
</div>
<div class="check-all" v-if="field.hasCheckAll" @click="checkAll(field)">全选</div>
</div>
</div>
data() {
return {
filter: Object.assign({
content: 'search_am',
asset_type: '资管类',
// inquiry_type: '资管类',
credit_manager_type: '金融机构主动管理',
product_invest: [],
asset_amount: '',
asset_life: []
}, lastSaved),
fields: [{
name: '*产品投向',
group: 'group2',
key: 'product_invest',
type: 'checkboxs',
validate: {
required: {
rule: true,
message: '请选择产品投向'
}
},
options: [{
key: '1',
value: '债券类'
}, {
key: '2',
value: '股票类'
}, {
key: '3',
value: '非标债权类'
}, {
key: 'other',
value: '其它'
}]
}]
}
}
v-model is a array data, validate is required.when selected checkbox more than one, the validatation is invalid