This article mainly introduces the use of the VUE-region selector (V-Distpicker) component. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
No nonsense Say more and get straight to the point.
Installation and citation are copied directly from the official website, so I won’t go into details.
1. Installation
Use npm to install:
npm install v-distpicker --save
Use yarn to install
yarn add v-distpicker --save
##2. Use
to register Componentimport VDistpicker from 'v-distpicker' Vue.component('v-distpicker', VDistpicker);
import VDistpicker from 'v-distpicker' export default { components: { VDistpicker } }
Simple to use
<v-distpicker></v-distpicker>
<v-distpicker province="广东省" city="广州市" area="海珠区"></v-distpicker>
<v-distpicker type="mobile"></v-distpicker>
3. The following are the key points
Get Selected value<template> <button @click="choose">点我选择区域</button> <p class="pwrap" v-if="show"> <v-distpicker type="mobile" @province="onChangeProvince" @city="onChangeCity" @area="onChangeArea"></v-distpicker> </p> </template>
<script> import VDistpicker from 'v-distpicker' export default { name: 'getAddress', components: { VDistpicker }, data() { return { show:false, } }, methods: { choose(){ this.show=!this.show }, onChangeProvince(a){ console.log(a) }, onChangeCity(a){ console.log(a) }, onChangeArea(a){ console.log(a) this.show=false } }, }
4. Style
Do you feel that the pop-up style is ugly?<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>
Vue form class parent-child component data transfer example
The above is the detailed content of Use of VUE-region selector (V-Distpicker) component. For more information, please follow other related articles on the PHP Chinese website!