el-checkbox默认值
时间: 2023-10-02 08:06:18 浏览: 140
el-checkbox的默认值可以通过v-model来设置。在上述代码中,v-model绑定了checkList变量,可以在data中设置checkList的初始值来设置el-checkbox的默认值。例如,可以将checkList的初始值设置为一个数组,数组中包含需要默认选中的选项的值。如下所示:
```
data() {
return {
checkList: ['选项1', '选项2'], // 设置默认选中的选项
}
}
```
这样,在页面加载时,el-checkbox就会默认选中checkList中的选项。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [el-checkbox出现的传值问题以及change事件传默认值](https://blog.csdn.net/DragonOfMoon/article/details/112986541)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [el-checkbox多选时默认赋值](https://blog.csdn.net/weixin_35958891/article/details/107927549)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文