Home > Article > Web Front-end > Detailed explanation of vue region selection component tutorial
This article mainly introduces the vue region selection component, which is mainly used for the operation of national regional data, including three-level linkage of provinces, cities, and districts, and the addition and deletion of regional data. This article focuses on introducing the detailed tutorial of the vue region selection component. , friends in need can refer to it
Overview
is mainly used for the operation of national regional data, including three-level linkage of provinces, cities and districts, the addition of regional data and Delete; When operating regional data, we have used tree-shaped region selection components before, but because the rendering was slow when operating a large amount of regional data, we changed to another data display form and interaction form, thus There is this component.
Note: This component is a vue.js component
demo
Please click here for early access demo
API
Props
Type | Description | |
---|---|---|
Array | The data of the area passed into the component |
Description | ||
---|---|---|
The area selected in the component |
Props
area
The area parameter is required and represents the region data when the component is initialized. , can be empty. area is an array containing multiple objects, where the data structure of each object is as follows:
... area: [ {Name: '北京', ID: '01'}, {Name: '南京', ID: '0401'}, {Name: '西湖区', ID: '060105'} ], ...Because later in actual use, I found that sometimes, The background will only return the ID value of one region, so optimization has been done here. You can only pass in the ID value, for example:
... area: [ {ID: '01'}, {ID: '0401'}, {ID: '060105'} ], ...##selected
selected is an event published internally by the component. You can subscribe to this event outside the component to get the value it returns. This value is all the areas currently selected by the component. The returned value It is an array composed of multiple objects containing regional data. The data structure is the same as the area parameter
Simple example<p>
<addressmap :area="area" @selected="selected"></addressmap>
</p>
npm install adc-addressmap
If used as a global component
//在项目入口文件 import Vue from 'vue' import Addressmap from 'adc-addressmap' Vue.component('Addressmap', Addressmap) 若作为局部组件 //在某个组件中 import Addressmap from 'adc-addressmap' export default { ... components: { Addressmap}, ... }
The above is the detailed content of Detailed explanation of vue region selection component tutorial. For more information, please follow other related articles on the PHP Chinese website!