vue + elementui 使用多选按钮实现单选功能
CommonRadio.vue <template>
<div>
<el-checkbox-group v-model="checkList" @change="handleChange">
<el-checkbox :label="item[keyId]" v-for="item in list" :key="item">{{item[label]}}</el-checkbox>
</el-checkbox-group>
</div>
</template> <script>
export default {
props: {
value: [String, Array],
list: {
type: Array,
default () {
return [];
}
},
keyId: {
type: String,
default: 'value',
},
label: {
type: String,
default: 'label'
},
},
data() {
return {
checkList: [],
}
},
watch: {
value: {
immediate: true,
handler(val) {
this.checkList = [ val ];
}
}
}, methods: {
handleChange(arr) {
this.checkList.length > 1 && this.checkList.shift(); this.$nextTick(() => {
let val = this.checkList.length > 0 ? this.checkList[0] : '';
this.$emit('change', val);
this.$emit('input', val);
})
}
},
}
</script> 调用 <div class="associated-list">
<template v-for="(item, index) in associatedList">
<el-form-item :label="item.name" :key="item" v-if=" (maxSize !== null ? index < maxSize : true)">
<CommonRadio v-model="associated[`tags_${item.id}`]" :list="item.tags" :keyId="`id`" :label="`name`"></CommonRadio>
</el-form-item>
</template> <div class="get-more">
<el-button type="text" @click="showMore" v-if="maxSize !== null && associatedList.length > 3">更多行为标签>></el-button>
</div>
</div>
vue + elementui 使用多选按钮实现单选功能的更多相关文章
- vue Element-ui 表格多选 修改选中行背景色
实现的效果: 整体思路方式: 1.给获取到的数据添加自定义的className 2.在点击行(row-click)和手动点击勾选框的事件(select-all)中获取到当前的row的className ...
- checkbox多选按钮变成单选
<input id="a" type="checkbox"/><input id="b" type="check ...
- elementui禁用全选按钮
document.getElementsByClassName('el-checkbox__input')[0].classList.add('is-disabled') doc ...
- layui 数据表格复选框实现单选功能
//点击选中(单选)//单击行勾选checkbox事件 $(document).on("click",".layui-table-body table.layui-tab ...
- vue+element-ui 项目中实现复制文字链接功能
需求: 点击复制按钮,复制一个链接 在GitHub上找到一个clipboard组件,功能比较齐全 使用方法: 安装 npm i clipboard --save HTML <template ...
- DataGridView复选框实现单选功能(二)
双击DataGridView进入事件 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventA ...
- vue+elementUI实现 分页表格的单选或者多选、及禁止部分选择
一.vue+elementUI实现 分页表格前的多选 多选效果图: 代码如下: <el-table ref="multipleTable" :data="listD ...
- iView的tree组件实现单选功能
iView中的树组件有复选框可以多选,但是目前还没有提供单选框的模式,不显示复选框可以提供高亮单选的模式,但是再次点击就被取消了,没有实现真正的单选: tree 的属性配置中 multiple 是否支 ...
- vue+element-ui实现表格checkbox单选
公司平台利用vue+elementui搭建前端页面,因为本人第一次使用vue也遇到了不少坑,因为我要实现的效果如下图所示 实现这种单选框,只能选择一个,但element-ui展示的是多选框,check ...
随机推荐
- Python中的虚拟环境的使用
1.安装virtualenv pip3 install virtualenv 2.创建目录 mkdir Myproject cd Myproject 3.创建独立运行环境-命名 virtualenv ...
- openresty开发系列33--openresty执行流程之2重写赋值阶段
openresty开发系列33--openresty执行流程之2重写赋值阶段 一)重写赋值阶段 1)set_by_lua 语法:set_by_lua $res <lua-script-str&g ...
- ES6新增函数总结和range函数实现
Array.from 类数组,Set,字符串转为数组 Array.of 不定参数转为数组 Array.prototype.fill(value,[start],[end]) 对数组在指定范围填充 ...
- xshell的ssh连接频繁提示Socket error Event: 32 Error: 10053(待验证)
修改/etc/ssh/sshd_config下的配置文件 将ClientAliveInterval的值修改为60 然后重启ssh服务器 目前没有在频繁出现ssh断开问题了,应该是有效的
- [LeetCode] 689. Maximum Sum of 3 Non-Overlapping Subarrays 三个非重叠子数组的最大和
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. E ...
- python爬虫2
学习任务 获取去哪儿网的出发地列表 获取旅游景点列表 获取景点产品列表 存储数据 1 获取出发地站点 (1)访问touch.qunar.com (2)按F12,单击自由行,在自由行页面点击搜索框 (3 ...
- Oracle通过命令导入数据存储文件
imp ztdev/ztdev FROMUSER=zt_base TOUSER=ztdev file=/home/oracle/zt_base_1023_sc_kk_new.dmp log=zt_ba ...
- Ubuntu查看与结束任务进程
1.打开终端 2.敲 ps -ef 查出进程的编号(就是PID那列) 3.输入 kill PID 即可(如果PID是123456,则kill 123456) 例如: 我想把splash关闭,直接输 ...
- php xml转array的方法
php xml转array的方法 <pre><?php $responseXml='<xml><appid>12</appid></xml& ...
- c++入门构造函数
一种方法: class Student{ public: //声明有默认参数的构造函数 Student(,,float=10); //声明成员函数 void total(); private: //声 ...