npm 安裝
npm install v-distpicker --save
Vue全局引入組件
import Distpicker from 'v-distpicker'
Vue.component('v-distpicker', Distpicker)
也可以那里需要,哪里引入
import VDistpicker from 'v-distpicker'
export default {
components: { VDistpicker }
}
<v-distpicker province="廣東省" city="廣州市" area="海珠區"></v-distpicker>
在聲明vue實例的時候,定義 一個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
},
