Front-end Vue customization is simple and practical, three-level linkage selector for Chinese provinces and cities

With the development of technology, the complexity of development is getting higher and higher. The traditional development method makes a system into a whole application. It often happens that a small change or the addition of a small function may cause the overall logic to change. The modification affects the whole body. Through component development, individual development and maintenance can be effectively achieved, and they can be combined at will. Greatly improve low development efficiency and reduce maintenance costs.

Componentization is the only way for any front-end application with complex business scenarios and products after multiple iterations. Componentization requires more than just the module splitting and decoupling seen on the surface. There is also a lot of work behind it to support componentization, such as module splitting strategies based on business characteristics, interaction methods between modules, and building systems. etc.

The components introduced in this article are:

The front-end Vue customization is simple and practical, and it is a three-level linkage selector for Chinese provinces and municipalities. Please visit the uni-app plug-in market address: https://ext.dcloud.net.cn/plugin?id=13118

 For more information on front-end components, please follow the WeChat public account: Front-end component development

The renderings are as follows:

84f87f22d8393a74bb6ffd743dd58be9.png

a1c1d34431d9f573429bfb9a11aea4cf.png

34b20b7e6ae02a555fba8f907b94a842.png

#### Instructions

```How to use

<!-- themeColor: theme color ref: set unique ref pickerValueDefault: default selection @onCancel: cancel event @onConfirm: confirm event -->

<cc-city-picker :themeColor="themeColor" ref="mpvueCityPicker" :pickerValueDefault="cityPickerValueDefault"

@onCancel="onCancel" @onConfirm="onConfirm"></cc-city-picker>

```

#### HTML code implementation part

```html

<template>

<view class="content">

<form @submit="formSubmit" @reset="formReset">

<!-- leftTitle: left title name: input box name value: input box selection value placeholder: placeholder @click: click event -->

<ccInputSelView leftTitle="Harvest address" name="location" :value="pickerText" placeholder="Please select a location"

@click="showMulLinkageThreePicker"></ccInputSelView>

<ccInputView leftTitle="Detailed address" name="address" :value="address" placeholder="Please enter the detailed address">

</ccInputView>

<!-- themeColor: theme color ref: set unique ref pickerValueDefault: default selection @onCancel: cancel event @onConfirm: confirm event -->

<cc-city-picker :themeColor="themeColor" ref="mpvueCityPicker" :pickerValueDefault="cityPickerValueDefault"

@onCancel="onCancel" @onConfirm="onConfirm"></cc-city-picker>

<view class="uni-btn-v">

<button class="botBtn" type="primary" form-type="submit">下一步</button>

<view class="tipText"> Note: Please ensure that the housing information you fill in is true and correct</view>

</view>

</form>

</view>

</template>

<script>

import ccInputSelView from '../../components/cc-inputSelView/ccInputSelView.vue'

import ccInputView from '../../components/cc-inputSelView/ccInputView.vue'

export default {

components: {

ccInputSelView,

ccInputView

},

data() {

return {

cityPickerValueDefault: [0, 0, 1],

themeColor: '#0BBBEF',

pickerText: '',

address: ''

}

},

methods: {

//Three-level linkage selection

showMulLinkageThreePicker() {

this.$refs.mpvueCityPicker.show()

},

onConfirm(e) {

this.pickerText = e.label

},

onCancel(e) {

console.log(e)

},

formSubmit: function(e) {

console.log('The submit event occurred in the form, and the data carried is: ' + JSON.stringify(e));

var formdata = e.detail.value;

uni.showModal({

title: 'Warm reminder',

content: 'The formsubmit event carries data:' + JSON.stringify(e.detail.value)

})

},

}

}

</script>

<style>

.content {

display: flex;

flex-direction: column;

}

.uni-btn-v {

width: 100%;

height: auto;

}

.botBtn {

width: 90%;

margin-top: 36px;

}

.tipText {

width: 100%;

margin-left: 0px;

text-align: center;

color: #666666;

margin-top: 36px;

margin-bottom: 36px;

font-size: 28rpx;

}

</style>

```

Guess you like

Origin blog.csdn.net/chenchuang0128/article/details/131299974