当前位置:网站首页>Use of three-level linkage plug-ins selected by provinces and cities
Use of three-level linkage plug-ins selected by provinces and cities
2022-06-25 10:54:00 【Stranger & love sorrow】
Be careful : This method can only be used in vue In the scaffold project of , If the project has npm install , It is recommended to use npm Way to install
install
npm install
npm install v-distpicker --save
yarn install
yarn add v-distpicker --save
register
main.js Registering global components
import VDistpicker from 'v-distpicker'
Vue.component('v-distpicker', VDistpicker);
In use vue Register in component
import VDistpicker from 'v-distpicker'
export default {
components: { VDistpicker }
}
Use
Based on using
<v-distpicker> </v-distpicker>
Usage with default values
<v-distpicker province=" Guangdong province, " city=" guangzhou " area=" Haizhu District "> </v-distpicker>
Usage of mobile terminal
<v-distpicker type="mobile"> </v-distpicker>
The specific use
html Code
<template>
<div>
<button @click="choose"> Click my selection area </button>
<p> The city you choose is :<span>{
{txt1}}</span><span>{
{txt2}}</span><span>{
{txt3}}</span></p>
<p class="pwrap" v-if="show">
<v-distpicker type="mobile" @province="onChangeProvince" @city="onChangeCity" @area="onChangeArea"></v-distpicker>
</p>
</div>
</template>
vue Code
<script>
import VDistpicker from 'v-distpicker'
export default {
name: 'getAddress',
components: { VDistpicker },
data() {
return {
show:false,
txt1:'',
txt2:'',
txt3:'',
}
},
methods: {
choose(){
this.show=!this.show
},
onChangeProvince(a){
console.log(a)
this.txt1 = a.value + '-'
},
onChangeCity(a){
console.log(a)
this.txt2 = a.value + '-'
},
onChangeArea(a){
console.log(a)
this.txt3 = a.value
this.show=false
}
},
}
</script>
Corresponding css style
<style scoped>
.pwrap{
height: 400px;
overflow-y: auto;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
}
.pwrap>>>.distpicker-address-wrapper{
color: #999;
}
.pwrap>>>.address-header{
position: fixed;
bottom: 400px;
width: 100%;
background: #000;
color:#fff;
}
.pwrap>>>.address-header ul li{
flex-grow: 1;
text-align: center;
}
.pwrap>>>.address-header .active{
color: #fff;
border-bottom:#666 solid 8px
}
.pwrap>>>.address-container .active{
color: #000;
}
</style>
Final renderings
边栏推荐
- Google Earth Engine(GEE)——evaluate實現一鍵批量下載研究區內的所有單張影像(上海市部分區域)
- Cdn+cos ultra detailed steps for drawing bed construction
- 手机办理广州证券开户靠谱安全吗?
- Is it safe to open an account with Guangzhou securities by mobile phone?
- 1-7Vmware中的快照与克隆
- 今天16:00 | 中科院计算所研究员孙晓明老师带大家走进量子的世界
- 性能之网络篇
- Nuxtjs actual combat case
- keep-alive
- 数组结构整理
猜你喜欢
Yolov5 changing the upper sampling mode
中国信通院沈滢:字体开源协议——OFL V1.1介绍及合规要点分析
Your driver settings have been set to force 4x antialiasing in OpenGL applications
网络远程访问的方式使用树莓派
FPGA基于VGA显示字符及图片
Complete steps for a complete Oracle uninstall
无心剑中译伊玛·拉扎罗斯《新巨人·自由女神》
[file inclusion vulnerability-04] classic interview question: how to getshell when a website is known to have only local file inclusion vulnerability?
Houdini图文笔记:Your driver settings have been set to force 4x Antialiasing in OpenGL applications问题的解决
Es learning
随机推荐
Flask blog practice - realize personal center and authority management
Shardingsphere proxy 5.0 sub database and sub table (I)
On binary tree
OpenCV学习(二)---树莓派上安装opencv
Detailed explanation of Android interview notes handler
单片机开发---基于ESP32-CAM的人脸识别应用
[200 opencv routines] 210 Are there so many holes in drawing a straight line?
一个五年北漂的技术er,根据这些年的真实经历,给应届生的一些建议
The path of Architects
今天16:00 | 中科院计算所研究员孙晓明老师带大家走进量子的世界
网络协议学习---LLDP协议学习
Growth: how to think deeply and learn
性能之文件系统篇
之前字符串反转的题目
性能之内存篇
Kotlin arrays and collections (1) {create arrays, use arrays, use for in loops to traverse arrays, use array indexes, and multi-dimensional arrays}
Handler asynchronous message processing
Think about it
【观察】ObjectScale:重新定义下一代对象存储,戴尔科技的重构与创新
Nuxtjs actual combat case