Home >Web Front-end >JS Tutorial >How to use vue region selection component
This time I will show you how to use vue region selection components, and what are the precautions for using vue region selection components. The following is a practical case, let's take a look.
Overview
is mainly used for the operation of regional data across the country, including linkage at the provincial, municipal and district levels, the addition andNote: This component is a vue.js component
demo
Please click here for early access demo
API
PropsType | Description | |
---|---|---|
The data of the area passed into the component |
ParametersDescription | ##selected | |
---|---|---|
Detailed description |
area
area parameter is required and represents the region data when the component is initialized. It can be empty. area is anarray containing multiple objects. 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 only returns one area. ID value, so optimization has been done here, you can only pass in the ID value, for example:
... area: [ {ID: '01'}, {ID: '0401'}, {ID: '060105'} ], ...selectedselected 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 is an array composed of multiple objects containing area data, data structure and area parameters. Same as
Simple example
<p> <addressmap :area="area" @selected="selected"></addressmap> </p>
Install and use
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}, ... }
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
How to use source JS code to implement Baidu search box
How to use jQuery.i18n.properties Internationalize JS code
The above is the detailed content of How to use vue region selection component. For more information, please follow other related articles on the PHP Chinese website!