<template>
<view class="content">
<view class="pay-item local">
<text>地区</text>
<pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
{{regionName?regionName:'省/市/区'}}
</pick-regions>
</view>
</view>
</template>
<script>
import pickRegions from '@/components/pick-regions/pick-regions.vue'
export default {
data() {
return {
region: [],
defaultRegion: ['广东省', '广州市', '番禺区'],
defaultRegionCode: '440113'
}
},
computed: {
regionName() {
// 转为字符串
return this.region.map(item => item.name).join(' ')
}
},
methods: {
// 获取选择的地区
handleGetRegion(region) {
console.log(region);
this.region = region
},
}
}
</script>
<style scoped>
.container {
background-color: #FCFCFE;
padding-top: 28upx;
}
text {
width: 210upx;
}
input {
width: calc(100% - 210upx);
}
.pay-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20upx;
min-height: 90upx;
background-color: #dfdfdf;
margin-bottom: 25upx;
font-size: 28upx;
color: #2B261E;
}
input {
font-size: 28upx;
}
.tip {
height: 50upx;
font-size: 24upx;
color: red;
text-align: end;
margin-top: -20upx;
display: none;
}
</style>
插件地址:
省市区三级联动选择器(支持APP、H5、小程序) - DCloud 插件市场
导入到项目下的components目录下,拷贝上面的代码就可看见效果
文章评论