You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#### 使用方法
1.HBuilderX导入直接在template组件中使用
2.使用npm安装
npm i zhilin-cascader
import ZhilinCascader from 'zhilin-cascader/zhilin-cascader'
```javascript
const options = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [{
value: 'hangzhou',
label: 'Hangzhou',
children: [{
value: 'xihu',
label: 'West Lake',
}]
}]
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [{
value: 'nanjing',
label: 'Nanjing',
children: [{
value: 'zhonghuamen',
label: 'Zhong Hua Men',
}]
}]
}
]
export default {
data() {
return {
options,
show: true
}
},
methods: {
onConfirm(value) {
console.log(value)
}
}
}
```
直接在 template 中使用组件
```html
<zhilin-cascader
v-model="show"
:options="options"
@confirm="onConfirm"
>
</zhilin-cascader>
```
#### 属性说明
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
| ------------ | ----------------- | ---- | -------- | :------------------------------------------------------- |
| v-model | Boolean | | | 控制选择器弹出/隐藏 |
| options | Array/ObjectArray | | | 格式:[{label:"四川",value:"sc",children:[]}] |
| title | String | | "请选择" | 选择器的标题 |
| isFullValue | Boolean | | false | 是否限制选择完每一项才能confirm |
| defaultSelected | Array | | | 初始选中项(必须与options数据value对应) |
| fieldNames | Object | | {label:'label',value:'value',children:'children'} | 自定义optionslabel value children的字段 |
| height | String | | 根据设备自适应 | 需要带上相应单位 |
#### 事件说明
| 事件名 | 说明 | 返回值 |
| ------- | -------------------- | ------------------------------------------------------- |
| change | 选中项发生改变时触发 | 接收当前选中项value,数组 |
| confirm | 点击确定时触发 | 接收当前选中项value,数组 |