国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 22:24:55
文檔

Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)

Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng):三級(jí)聯(lián)動(dòng),隨著越來越多的審美,出現(xiàn)了很多種,好多公司都仿著淘寶的三級(jí)聯(lián)動(dòng) ,好看時(shí)尚,so我們公司也一樣……為了貼代碼方便,我把寫在data里面省市區(qū)的json獨(dú)立了出來,下載貼進(jìn)去即可用,鏈接如下:vue.json(這個(gè)直接是個(gè)data,放入你的vue2項(xiàng)目中即
推薦度:
導(dǎo)讀Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng):三級(jí)聯(lián)動(dòng),隨著越來越多的審美,出現(xiàn)了很多種,好多公司都仿著淘寶的三級(jí)聯(lián)動(dòng) ,好看時(shí)尚,so我們公司也一樣……為了貼代碼方便,我把寫在data里面省市區(qū)的json獨(dú)立了出來,下載貼進(jìn)去即可用,鏈接如下:vue.json(這個(gè)直接是個(gè)data,放入你的vue2項(xiàng)目中即

三級(jí)聯(lián)動(dòng),隨著越來越多的審美,出現(xiàn)了很多種,好多公司都仿著淘寶的三級(jí)聯(lián)動(dòng) ,好看時(shí)尚,so我們公司也一樣……為了貼代碼方便,我把寫在data里面省市區(qū)的json獨(dú)立了出來,下載貼進(jìn)去即可用,鏈接如下:vue.json(這個(gè)直接是個(gè)data,放入你的vue2項(xiàng)目中即可。(因?yàn)槲业捻?xiàng)目是用的vue2,所以,其他的屬性跟博客內(nèi)容是吻合的。請(qǐng)配合博客再下載此json))。

首先頁面顯示如下:

然后我們縣級(jí)所在地區(qū)會(huì)出現(xiàn)三級(jí)聯(lián)動(dòng),如下:(以下是片段,背景色未截取)

這個(gè)張什么樣,以什么形式出現(xiàn),取決于貴公司的UI需求,我們公司是做成彈出層了。然后背景色透明,這里為了節(jié)省流量,我只截取了一段,最后顯示如下:

如果貴公司也跟我們需求一樣,希望這個(gè)可以幫到你們。下面是在vue2項(xiàng)目中寫的三級(jí)聯(lián)動(dòng)代碼以及css樣式:
<template>

 <section class="myAddress">
 <section>
 <section class="cont" @click="choseAdd()">
 <section>
 <span>所在地區(qū):{{Province?Province:''}} {{City?City:''}} {{District?District:''}}</span>
 </section>
 <img src="../../assets/main/right.png" alt="">
 <div style="clear: both"></div>
 </section>
 </section>
 <!-- 居住地址三級(jí)聯(lián)動(dòng)選項(xiàng) -->
 <section class="showChose" v-show="showChose">
 <section class="address">
 <section class="title">
 <h4>居住地址</h4>
 <span @click="closeAdd()">×</span>
 </section>
 <section class="title">
 <div class="area" @click="provinceSelected()">
 {{Province?Province:info[province-1].name}}
 </div>
 <div class="area" @click="citySelected()" :class="City?'':'active'">
 {{City?City:'請(qǐng)選擇'}}
 </div>
 <div class="area" @click="districtSelected()" :class="District?'':'active'" v-show="City">
 {{District?District:'請(qǐng)選擇'}}
 </div>
 </section>
 <ul>
 <li class="addList" v-for="(v,k) in info" 
 @click="getProvinceId(v.id, v.name, k)" 
 v-show="showProvince" 
 :class="v.selected ? 'active' : ''">{{v.name}}</li>
 <li class="addList" v-for="(v,k) in showCityList" 
 @click="getCityId(v.id, v.name, k)" 
 v-show="showCity" 
 :class="v.selected ? 'active' : ''">{{v.name}}</li>
 <li class="addList" v-for="(v,k) in showDistrictList" 
 @click="getDistrictId(v.id, v.name, k)" 
 v-show="showDistrict" 
 :class="v.selected ? 'active' : ''">{{v.name}}</li>
 </ul>
 </section>
 </section>
 <!-- 頁面內(nèi)容 -->
 <section class="cont">
 <span>詳細(xì)地址:</span>
 <input type="text" v-model="address" placeholder=" 請(qǐng)?zhí)顚懺敿?xì)地址">
 </section>
 </section>
</template>
<script>
 import {
 mapActions,
 mapGetters
 } from 'vuex';
 import api from './../../fetch/api.js'
 export default {
 name: 'address',
 data(){},此處的data直接下載json復(fù)制進(jìn)去即可。http://download.csdn.net/detail/zhaohaixin0418/9862255。
 components: {
 MineHeader
 },
 computed: {
 ...mapGetters([
 'BCcontextPathSrc',
 'sessionId',
 'token',
 ]),
 },
 methods: {
 choseAdd: function() {
 this.showChose = true;
 },
 closeAdd: function() {
 this.showChose = false;
 },
 _filter(add, name, code) {
 let result = [];
 for (let i = 0; i < add.length; i++) {
 if (code == add[i].id) {
 result = add[i][name];
 }
 }
 return result;
 },
 getProvinceId: function(code, input, index) {
 this.province = code;
 this.Province = input;
 this.showProvince = false;
 this.showCity = true;
 this.showDistrict = false;
 this.showCityList = this._filter(this.info, 'city', this.province);
 // 點(diǎn)擊選擇當(dāng)前
 this.info.map(a => a.selected = false);
 this.info[index].selected = true;
 this.areaProvince = input;
 },
 provinceSelected: function() {
 // 清除市級(jí)和區(qū)級(jí)列表
 this.showCityList = false;
 this.showDistrictList = false;
 // 清除市級(jí)和區(qū)級(jí)選項(xiàng)
 this.City = false;
 this.District = false;
 // 選項(xiàng)頁面的切換
 this.showProvince = true;
 this.showCity = false;
 this.showDistrict = false;
 },
 getCityId: function(code, input, index) {
 this.city = code;
 this.City = input;
 this.showProvince = false;
 this.showCity = false;
 this.showDistrict = true;
 this.showDistrictList = this._filter(this.showCityList, 'district', this.city);
 // 選擇當(dāng)前添加active
 this.showCityList.map(a => a.selected = false);
 this.showCityList[index].selected = true;
 this.areaCity = input;
 },
 citySelected: function() {
 this.showProvince = false;
 this.showCity = true;
 this.showDistrict = false;
 },
 getDistrictId: function(code, input, index) {
 this.district = code;
 this.District = input;
 // 選擇當(dāng)前添加active
 this.showDistrictList.map(a => a.selected = false);
 this.showDistrictList[index].selected = true;
 // 選取市區(qū)選項(xiàng)之后關(guān)閉彈層
 this.showChose = false;
 this.areaDistrict = input;
 },
 districtSelected: function() {
 this.showProvince = false;
 this.showCity = false;
 this.showDistrict = true;
 },
 saveProfile: function() {
 api.commonApi('后臺(tái)接口', 這里是貴公司后臺(tái)接口,按照你們公司的改了就好
 'param_key={"head":{"TYPE":"ADD_UPD_INFO",' +
 '"SESSION_ID":"' + this.sessionId + '",' +
 '"TOKEN":"' + this.token + '","DEVICE_ID":""},' +
 '"param":{"PROVINCE":"' + this.areaProvince + '", ' +
 '"CITY":"' + this.areaCity + '", "COUNTY":"' + this.areaDistrict + '",' +
 '"ADDRESS": "' + this.address + '"}}')
 .then(res => {
 console.log(res.data);
 });
 }
 }
 }
</script>
<style scoped>
 .myAddress {
 width: 100%;
 background-color: white;
 border-top: 4px solid rgba(245, 245, 245, 1);
 color: #333;
 }
 .myAddress .cont {
 border-bottom: 1px solid rgba(245, 245, 245, 0.8);
 }
 .myAddress .cont span {
 display: inline-block;
 font-size: 0.28rem;
 color: #333;
 line-height: 0.88rem;
 margin-left: 0.32rem;
 }
 .myAddress .cont section {
 float: left;
 }
 .myAddress .cont img {
 float: right;
 width: 0.14rem;
 height: 0.24rem;
 margin: 0.32rem 0.32rem 0.32rem 0;
 }
 .showChose {
 width: 100%;
 height: 100%;
 position: fixed;
 top: 0;
 left: 0;
 z-index: 120;
 background: rgba(77, 82, 113, 0.8);
 }
 .address {
 position: absolute;
 bottom: 0;
 left: 0;
 z-index: 121;
 background: #fff;
 width: 100%;
 }
 .title h4 {
 display: inline-block;
 margin-left: 3.2rem;
 font-size: 0.32rem;
 line-height: 0.88rem;
 font-weight: normal;
 color: #999;
 }
 .title span {
 margin: 0.42rem 0 0 2.2rem;
 font-size: 0.45rem;
 line-height: 0.34rem;
 color: #D8D8D8;
 }
 .area {
 display: inline-block;
 font-size: 0.24rem;
 line-height: 0.88rem;
 margin-left: 0.42rem;
 color: #333;
 }
 .addList {
 padding-left: 0.32rem;
 font-size: 0.34rem;
 line-height: 0.88rem;
 color: #333;
 }
 /* 修改的格式 */
 .address ul {
 height: 100%;
 margin-left: 5%;
 max-height: 4.4rem;
 overflow: auto;
 }
 .address .title .active {
 color: #0071B8;
 border-bottom: 0.02rem solid #0071B8;
 }
 .address ul .active {
 color: #0071B8;
 }
</style>

這樣就完成了一個(gè)省市區(qū)的三級(jí)聯(lián)動(dòng)。

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)

Vue2仿淘寶實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng):三級(jí)聯(lián)動(dòng),隨著越來越多的審美,出現(xiàn)了很多種,好多公司都仿著淘寶的三級(jí)聯(lián)動(dòng) ,好看時(shí)尚,so我們公司也一樣……為了貼代碼方便,我把寫在data里面省市區(qū)的json獨(dú)立了出來,下載貼進(jìn)去即可用,鏈接如下:vue.json(這個(gè)直接是個(gè)data,放入你的vue2項(xiàng)目中即
推薦度:
標(biāo)簽: 淘寶 VUE 省市
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 欧美一区二区三区网站 | 98成人网 | 91麻精品国产91久久久久 | 国产最新进精品视频 | 国产成人综合精品一区 | 在线欧美色图 | 精品国产不卡一区二区三区 | 亚洲欧美久久精品一区 | 亚洲欧美综合图区官网 | 欧美日韩国产在线观看 | 成人免费久久精品国产片久久影院 | 亚洲欧美激情精品一区二区 | 曰韩在线 | 国产成人精品一区二三区在线观看 | 国产区一区 | 欧美日韩视频一区二区在线观看 | 亚洲欧美日韩专区 | 国产精品久久久久久免费播放 | 3女bbbwww| 欧美一区二区三区视频在线 | 国产欧美一区二区三区视频 | 亚洲最新视频在线观看 | 福利视频二区 | 最新国产网址 | 日韩视频一区二区在线观看 | a级黄色毛片 | 亚洲色图欧美激情 | 伊人久久中文字幕久久cm | 99久久综合国产精品免费 | 国产精品成人久久久 | 亚洲国产成人影院播放 | 欧美亚洲综合一区 | 91视频国产91久久久 | 欧美午夜一区二区福利视频 | 三区在线观看 | 国产91一区二这在线播放 | 成人国产精品免费网站 | 欧美日韩国产在线播放 | 午夜一区二区三区 | 一区二区三区久久 | a在线视频 |