UNPKG

856 BPlain TextView Raw
1<template>
2 <van-popup position="bottom" v-model="show" :close-on-click-overlay="false">
3 <van-picker v-bind="$attrs" show-toolbar :columns="columns" @confirm="confirm" @cancel="close" />
4 </van-popup>
5</template>
6<script>
7/**
8 * @param {Array} columns - 列表数据
9 * @param {Boolean} show.sync - 显示/隐藏
10 * @param {Function} change({value,index})
11 */
12export default {
13 props: {
14 columns: {
15 type: Array,
16 default: () => []
17 },
18 show: {
19 type: Boolean,
20 default: false
21 }
22 },
23 data() {
24 return {
25 showPicker: false,
26 value: ""
27 };
28 },
29 methods: {
30 close() {
31 this.$emit("update:show", false);
32 },
33 confirm(value, index) {
34 this.close();
35 this.value = value;
36 this.$emit("change", { value, index });
37 }
38 }
39};
40</script>
\No newline at end of file