当前位置:网站首页>Pits encountered in the use of El checkbox group
Pits encountered in the use of El checkbox group
2022-07-03 06:53:00 【God】
What you want to achieve el-checkbox-group multi-select 、 Form validation required
<!-- Error code -->
<el-dialog
title=" Configuration details "
width="395px"
center
>
<el-form
:model="configInfo"
id="form"
ref="form"
:rules="rules"
size="small"
label-position="right"
label-width="120px"
>
<el-form-item label=" Account combination " prop="checkedSubjectIdList">
<el-checkbox-group v-model="configInfo.checkedSubjectIdList">
<el-checkbox v-for="(item,index) in subjectList"
:key="item.subjectId"
:label="item.subjectId"
:class="index%2===1 ? 'cfr':''"
>{
{item.subjectName}}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
</el-dialog>
// data structure
data () {
return {
configInfo: {
checkedSubjectIdList: [], // Account combination id
},
subjectList:[
{subjectId:'1',subjectName:'abc'},
{subjectId:'2',subjectName:'cde'}
],
rules: {
checkedSubjectIdList: [{type:'array',required: true, message: ' Mandatory ', trigger: 'change'}],
}
}
}
Error reason , It seems that the data structure is deep ,<el-checkbox-group v-model="configInfo.checkedSubjectIdList"> hold checkedSubjectIdList Take it out alone , Do not nest , To such <el-checkbox-group v-model="checkedSubjectIdList">,:required="true" In order to label There is ‘*’, because checkedSubjectIdList be not in form The binding of configInfo Inside ,rules Also on the checkedSubjectIdList useless , So I have to submit it manually if(this.checkedSubjectIdList.length === 0) Judging empty arrays (( Make do with ......)).
<!-- Corrected code -->
<el-dialog
title=" Configuration details "
width="395px"
center
>
<el-form
:model="configInfo"
id="form"
ref="form"
:rules="rules"
size="small"
label-position="right"
label-width="120px"
>
<el-form-item label=" Account combination " :required="true">
<el-checkbox-group v-model="checkedSubjectIdList">
<el-checkbox v-for="(item,index) in subjectList"
:key="item.subjectId"
:label="item.subjectId"
:class="index%2===1 ? 'cfr':''"
>{
{item.subjectName}}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
</el-dialog>
// data structure
data () {
return {
configInfo: {
},
checkedSubjectIdList: [], // Account combination id
subjectList:[
{subjectId:'1',subjectName:'abc'},
{subjectId:'2',subjectName:'cde'}
],
rules: {
}
}
}边栏推荐
- Unit test framework + Test Suite
- php artisan
- opencv鼠标键盘事件
- La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ
- Yolov3 learning notes
- The dynamic analysis and calculation of expressions are really delicious for flee
- Interface learning
- [C /vb.net] convert PDF to svg/image, svg/image to PDF
- 【LeetCode】Day93-两个数组的交集 II
- vmware虚拟机C盘扩容
猜你喜欢

10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”

Numerical method for solving optimal control problem (I) -- gradient method
![[untitled]](/img/72/4ff9354634342580a135debb58b60e.jpg)
[untitled]

My 2020 summary "don't love the past, indulge in moving forward"

SQL implementation merges multiple rows of records into one row

Summary of UI module design and practical application of agent mode

如何迁移或复制VMware虚拟机系统

Selenium - by changing the window size, the width, height and length of different models will be different

Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)

2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
随机推荐
Scroll view specifies the starting position of the scrolling element
【类和对象】深入浅出类和对象
Know flex box
远端rostopic的本地rviz调用及显示
pytorch练习小项目
论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
golang操作redis:写入、读取hash类型数据
方差迭代公式推导
[LeetCode]404. 左叶子之和
学习笔记 -- k-d tree 和 ikd-Tree 原理及对比
Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
How does the insurance company check hypertension?
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Software testing assignment - the next day
centos php7.2.24升级到php7.3
【code】if (list != null && list.size() > 0)优化,集合判空实现方式
Interface test weather API
ssh链接远程服务器 及 远程图形化界面的本地显示
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?