Home > Web Front-end > JS Tutorial > body text

Detailed explanation of vue region selection component tutorial

不言
Release: 2018-05-04 14:51:56
Original
1356 people have browsed it

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


##ParametersTypeDescription##areaEvents
Array The data of the area passed into the component


##Event nameParameters DescriptionselectedareaThe area selected in the componentDetailed description

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'}
],
...
Copy after login

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'}
],
...
Copy after login

##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>
Copy after login

Installation and use

npm install adc-addressmap

If used as a global component

//在项目入口文件
import Vue from &#39;vue&#39;
import Addressmap from &#39;adc-addressmap&#39;
Vue.component(&#39;Addressmap&#39;, Addressmap)
若作为局部组件
//在某个组件中
import Addressmap from &#39;adc-addressmap&#39;
export default {
...
 components: { Addressmap},
...
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!