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.
52 lines
1006 B
52 lines
1006 B
<template>
|
|
<view style="width: 100%;">
|
|
<u-input :value="value" type="select" @click="show = true" :placeholder="placeholder"/>
|
|
<u-picker mode="region" v-model="show" :area-code='areaCode' @confirm="onConfirm"></u-picker>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
value: {
|
|
type: String,
|
|
default: null
|
|
},
|
|
areaCode: {
|
|
type: Array,
|
|
default: function() {
|
|
["11", "1101", "110101"]
|
|
}
|
|
},
|
|
valueFor: {
|
|
type: String,
|
|
default: "address"
|
|
},
|
|
placeholder: {
|
|
type: String,
|
|
default: '请选择'
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
show: false
|
|
}
|
|
},
|
|
methods: {
|
|
onConfirm(params) {
|
|
let p = params['province'];
|
|
let c = params['city'];
|
|
let a = params['area'];
|
|
if (this.valueFor == 'address') {
|
|
this.$emit("input", p.label + "," + c.label + "," + a.label);
|
|
}else if (this.valueFor == 'code') {
|
|
this.$emit("input", p.value + "," + c.value + "," + a.value);
|
|
}
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style>
|