Picker
<template>
<div>
<p>{{pcaItems[0] ? pcaItems[0].name : '- 省 -'}} / {{pcaItems[1] ? pcaItems[1].name : '- 市 -'}} / {{pcaItems[2] ? pcaItems[2].name : '- 区 -'}}</p>
<z-button @click="togglePicker">显示picker</z-button>
<p>
<z-picker
:visible="pickerVisible"
@confirm="pickerChange"
@cancel="cancelPicker"
:value="pickerValue"
:data="dataList"
valueKey="code"
title="请选择省市区"
></z-picker>
</p>
</div>
</template>
<script>
import Picker from "../../../src/components/picker/picker.vue";
import pca from "../../../src/components/picker/pca.js";
import Button from "../../../src/components/button/button.vue";
export default {
components: {
"z-picker": Picker,
"z-button": Button
},
data() {
return {
pickerVisible: false,
pickerValue: [],
pcaItems: [],
dataList: pca
};
},
methods: {
togglePicker() {
this.pickerVisible = !this.pickerVisible;
},
pickerChange(value, data) {
this.pickerValue = value;
this.pcaItems = data;
this.pickerVisible = false;
},
cancelPicker() {
this.pickerVisible = false;
}
}
};
</script>
Props
属性 | 含义 | 类型 | 默认 |
---|---|---|---|
visible | 控制组件显示隐藏 | Boolean | false |
data | 组件展示数据 | Array | [ ] |
valueKey | 数据中对应的值字段 | String | id |
labelKey | 数据展示对应的字段 | String | name |
childrenKey | 数据中嵌套的数据字段 | String | children |
title | 组件头部标题 | String | |
value | 组件选中的值 | Array | [ ] |
showModel | 是否显示蒙板 | Boolean | true |
maskClosable | 点击蒙板是否关闭 | Boolean | true |
Events
事件 | 含义 | 类型 | 默认 |
---|---|---|---|
cancel | 点击取消触发 | Function: ()=>{} | |
confirm | 点击确定触发 | Function: (values, data)=>{} |