Element-UI中Cascader 级联选择器使用

Element-UI的级联组件官方文档

  <el-cascader
    v-model="value"
    :options="options"
    :props="{ expandTrigger: 'hover' }"
    @change="handleChange"></el-cascader>

说明:
options:绑定数据源
props:数据配置项
v-model=“value”:双向绑定级联选择框中选中的value值
@change=“handleChange” :当级联选择框变化,触发handleChange事件,可返回选中项的值
使用:

<!--级联选择框-->
<el-cascader
                v-model="selectedKeys"
                :options="parentList"
                :props="cascaderProps"
                @change="parentCateChange" 
                clearable></el-cascader>
export default(){
	data(){
		return {
			//选中项的cat_id数组
			selectedKeys:[],
			//数据源信息
			parentList:{},
			//数据的配置信息
			cascaderProps:{
				//可以选中一级内容
				checkStrictly:true,
                //指定触发方式
                expandTrigger: 'hover',
				//数据源parantList中的cat_id做数据绑定
				value:'cat_id',
				//数据源parantList的cat_name渲染出来的内容
				label:'cat_name',
				//数据源parantList的children做嵌套
				children:'children'
			}	
		}
	},
	methods:{
		handleChange(){
			console.log(this.selectedKeys)
		}
	}	
}

注:·el-cascader中的clearable属性表示点击叉可清空选中框内容
在这里插入图片描述

评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值