vue achieve three linkage downtown province

npm install

npm install v-distpicker --save

Vue global introduction of components

import Distpicker from 'v-distpicker'


Vue.component('v-distpicker', Distpicker)

There may also be required, where the introduction of 

import VDistpicker from 'v-distpicker'
 
export default {
  components: { VDistpicker }
}
<V-distpicker province = "Guangdong" city = "Guangzhou" area = "Haizhu"> </ v-distpicker>

When declaring vue instance, define a method onSelected

 

<v-distpicker province="广东省" city="广州市" area="海珠区" @selected="onSelected"></v-distpicker>


onSelected(data) {
      this.address.province = data.province.value
      this.address.city = data.city.value
      this.address.county = data.area.value
},

  

 

Guess you like

Origin www.cnblogs.com/wuliujun521/p/11530013.html