Files
smart-admin/smart-admin-h5/src/components/form/select-picker/SmartSelectPicker
zhuoda 1f75c9614e v1.x
2022-11-05 22:38:44 +08:00

60 lines
956 B
Plaintext

<template>
<div>
<van-field
v-model="result"
v-bind="$attrs"
readonly
is-link
@click="show = !show"
/>
<van-popup v-model="show" position="bottom">
<van-picker
value-key="value"
:columns="columns"
show-toolbar
:title="$attrs.label"
@cancel="show = !show"
@confirm="onConfirm"
/>
</van-popup>
</div>
</template>
<script>
export default {
model: {
prop: 'selectValue'
},
props: {
columns: {
type: Array
},
selectValue: {
type: String
}
},
data() {
return {
show: false,
result: this.selectValue
};
},
methods: {
onConfirm(value) {
this.result = value;
this.show = !this.show;
}
},
watch: {
selectValue: function(newVal) {
this.result = newVal;
},
result(newVal) {
this.$emit('input', newVal);
}
}
};
</script>
<style></style>