最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue實(shí)現(xiàn)省市區(qū)級(jí)聯(lián)下拉選擇框

 更新時(shí)間:2022年03月04日 11:41:28   作者:theMuseCatcher  
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)省市區(qū)級(jí)聯(lián)下拉選擇框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Vue實(shí)現(xiàn)省市區(qū)級(jí)聯(lián)下拉選擇框的具體代碼,供大家參考,具體內(nèi)容如下

(Vue下拉選擇框Select組件二)為基礎(chǔ)實(shí)現(xiàn)省市區(qū)級(jí)聯(lián)下拉選擇框組件

(業(yè)務(wù)需要,固定省份選擇為貴州,沒(méi)有此業(yè)務(wù),不傳disabled屬性即可)

效果圖如下:

 ①創(chuàng)建級(jí)聯(lián)下拉選擇Cascader.vue組件

<template>
? <div class="m-cascader-wrap">
? ? <Select
? ? ? class="mr10"
? ? ? :style="`z-index: ${zIndex};`"
? ? ? mode="region"
? ? ? :disabled="true"
? ? ? :selectData="provinceData"
? ? ? :selValue="address.province"
? ? ? :width="84"
? ? ? placeholder="請(qǐng)選擇省"
? ? ? @getValue="getProvinceCode" />
? ? <Select
? ? ? class="mr10"
? ? ? :style="`z-index: ${zIndex};`"
? ? ? mode="region"
? ? ? :selectData="cityData"
? ? ? :selValue="address.city"
? ? ? :width="172"
? ? ? placeholder="請(qǐng)選擇市"
? ? ? @getValue="getCityCode" />
? ? <Select
? ? ? mode="region"
? ? ? :style="`z-index: ${zIndex};`"
? ? ? :selectData="areaData"
? ? ? :selValue="address.area"
? ? ? :width="172"
? ? ? placeholder="請(qǐng)選擇區(qū)"
? ? ? @getValue="getAreaCode" />
? </div>
</template>
<script>
import Select from '@/components/Select'
import { dictByType } from '@/api/index'
export default {
? name: 'Cascader',
? components: {
? ? Select
? },
? props: {
? ? selectedAddress: { // 省市區(qū)初始值
? ? ? type: Object,
? ? ? default: () => {
? ? ? ? return {}
? ? ? }
? ? },
? ? zIndex: {
? ? ? type: Number,
? ? ? default: 1
? ? }
? },
? data () {
? ? return {
? ? ? provinceData: [
? ? ? ? {
? ? ? ? ? dictVal: '貴州省',
? ? ? ? ? dictKey: 'P29'
? ? ? ? }
? ? ? ],
? ? ? cityData: [],
? ? ? areaData: [],
? ? ? regionParams: {
? ? ? ? type: '1',
? ? ? ? parentDictKey: ''
? ? ? },
? ? ? address: {
? ? ? ? province: 'P29',
? ? ? ? city: this.selectedAddress.city || '',
? ? ? ? area: this.selectedAddress.area || ''
? ? ? },
? ? ? addressName: {
? ? ? ? provinceName: '貴州省',
? ? ? ? cityName: '',
? ? ? ? areaName: ''
? ? ? },
? ? ? initialCity: true
? ? }
? },
? created () {
? ? this.getCity('P29')
? ? console.log('address:', this.address)
? },
? methods: {
? ? getCity (key) { // 獲取市數(shù)據(jù)
? ? ? this.regionParams.parentDictKey = key
? ? ? dictByType(this.regionParams).then(res => {
? ? ? ? console.log('city-res:', res)
? ? ? ? if (res.message.code === 0) {
? ? ? ? ? if (res.data.dataList) {
? ? ? ? ? ? this.cityData = res.data.dataList
? ? ? ? ? ? if (this.initialCity && this.address.city) {
? ? ? ? ? ? ? this.initialCity = false
? ? ? ? ? ? ? this.cityData.forEach(item => {
? ? ? ? ? ? ? ? if (item.dictKey === this.address.city) {
? ? ? ? ? ? ? ? ? this.getArea(item.dictKey)
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? })
? ? ? ? ? ? }
? ? ? ? ? ? console.log('cityData:', this.cityData)
? ? ? ? ? }
? ? ? ? }
? ? ? })
? ? },
? ? getArea (key) { // 獲取區(qū)數(shù)據(jù)
? ? ? this.regionParams.parentDictKey = key
? ? ? dictByType(this.regionParams).then(res => {
? ? ? ? console.log('area-res:', res)
? ? ? ? if (res.message.code === 0) {
? ? ? ? ? if (res.data.dataList) {
? ? ? ? ? ? this.areaData = res.data.dataList
? ? ? ? ? ? console.log('areaData:', this.areaData)
? ? ? ? ? }
? ? ? ? }
? ? ? })
? ? },
? ? getProvinceCode (name, key) {
? ? ? console.log('province:', name, key)
? ? },
? ? getCityCode (name, key) {
? ? ? console.log('city:', name, key)
? ? ? this.address.city = key
? ? ? this.addressName.cityName = name
? ? ? this.$emit('getAddress', {}, {})
? ? ? // 獲取區(qū)下拉列表
? ? ? this.getArea(key)
? ? },
? ? getAreaCode (name, key) {
? ? ? console.log('area:', name, key)
? ? ? this.address.area = key
? ? ? this.addressName.areaName = name
? ? ? this.$emit('getAddress', this.address, this.addressName)
? ? }
? }
}
</script>
<style lang="less" scoped>
.m-cascader-wrap {
? display: inline-block;
? width: 449px;
? height: 40px;
? line-height: 40px;
}
</style>

②在要使用的頁(yè)面引入:

<Cascader
? :selectedAddress="register"
? mode="region"
? :zIndex="997"
? @getAddress="getRegisterAddress" />
import Cascader from '@/components/Cascader'
components: {
? ? Cascader
},
data () {
? return {
? ? register: {
? ? ? province: this.data.registerProvinceCode,
? ? ? city: this.data.registerCityCode,
? ? ? area: this.data.registerAreaCode
? ? } || {},
? }
}
methods: {
? getRegisterAddress (address, addressName) {
? ? console.log('register-address:', address)
? ? this.register = address
? ? if (JSON.stringify(addressName) !== '{}') { // 用于提交表單
? ? ? this.addParams.registerProvinceName = addressName.provinceName
? ? ? this.addParams.registerCityName = addressName.cityName
? ? ? this.addParams.registerAreaName = addressName.areaName
? ? }
? ? if (JSON.stringify(address) !== '{}') { // 用于校驗(yàn)下拉表單是否未選擇
? ? ? this.checkFocus('register')
? ? }
? }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue3樣式滲透之deep()為什么無(wú)效詳解

    Vue3樣式滲透之deep()為什么無(wú)效詳解

    項(xiàng)目開(kāi)發(fā)中因?yàn)閡i設(shè)計(jì)常常需要修改vue常用的組件庫(kù)(element,antD等等),這就需要用到樣式穿透,下面這篇文章主要給大家介紹了關(guān)于Vue3樣式滲透之deep()為什么無(wú)效的相關(guān)資料,需要的朋友可以參考下
    2022-11-11
  • Vue通過(guò)懶加載提升頁(yè)面響應(yīng)速度

    Vue通過(guò)懶加載提升頁(yè)面響應(yīng)速度

    這篇文章主要介紹了Vue通過(guò)懶加載提升頁(yè)面響應(yīng)速度,對(duì)Vue性能感興趣的同學(xué),可以參考下
    2021-05-05
  • Vue3模板引用的操作方式示例詳解

    Vue3模板引用的操作方式示例詳解

    這篇文章主要為大家介紹了Vue3模板引用的操作方式示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06
  • Vue動(dòng)態(tài)組件component的深度使用說(shuō)明

    Vue動(dòng)態(tài)組件component的深度使用說(shuō)明

    這篇文章主要介紹了Vue動(dòng)態(tài)組件component的深度使用說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • npm run dev報(bào)錯(cuò)信息及解決方法

    npm run dev報(bào)錯(cuò)信息及解決方法

    這篇文章主要為大家介紹了npm run dev報(bào)錯(cuò)信息及解決方法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • Vue+Express實(shí)現(xiàn)登錄狀態(tài)權(quán)限驗(yàn)證的示例代碼

    Vue+Express實(shí)現(xiàn)登錄狀態(tài)權(quán)限驗(yàn)證的示例代碼

    這篇文章主要介紹了Vue+Express實(shí)現(xiàn)登錄狀態(tài)權(quán)限驗(yàn)證的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-05-05
  • vue-cli如何關(guān)閉Uncaught?error的全屏提示

    vue-cli如何關(guān)閉Uncaught?error的全屏提示

    這篇文章主要介紹了vue-cli如何關(guān)閉Uncaught?error的全屏提示問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • vue實(shí)現(xiàn)懸浮球效果

    vue實(shí)現(xiàn)懸浮球效果

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)懸浮球效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Vue組件層級(jí)關(guān)系詳細(xì)分析

    Vue組件層級(jí)關(guān)系詳細(xì)分析

    這篇文章主要介紹了Vue組件的層級(jí)關(guān)系,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • vue-cli中的babel配置文件.babelrc實(shí)例詳解

    vue-cli中的babel配置文件.babelrc實(shí)例詳解

    Babel是一個(gè)廣泛使用的轉(zhuǎn)碼器,可以將ES6代碼轉(zhuǎn)為ES5代碼,從而在現(xiàn)有環(huán)境執(zhí)行。本文介紹vue-cli腳手架工具根目錄的babelrc配置文件,感興趣的朋友一起看看吧
    2018-02-02

最新評(píng)論

黄冈市| 新巴尔虎左旗| 巴彦淖尔市| 翁源县| 松潘县| 太仆寺旗| 清远市| 庆阳市| 莱芜市| 平乡县| 沁源县| 桐城市| 太康县| 治县。| 永城市| 寿光市| 文昌市| 原阳县| 九江县| 汝城县| 安陆市| 太和县| 青浦区| 阿克陶县| 罗甸县| 湘乡市| 呼玛县| 同德县| 望谟县| 南陵县| 于田县| 延安市| 郑州市| 策勒县| 宁海县| 梧州市| 车致| 濉溪县| 大英县| 鹿泉市| 临海市|