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

vue實現手機端省市區(qū)區(qū)域選擇

 更新時間:2021年10月21日 15:55:48   作者:小羽向前跑  
這篇文章主要為大家詳細介紹了vue實現手機端省市區(qū)區(qū)域選擇,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue實現手機端省市區(qū)區(qū)域選擇的具體代碼,供大家參考,具體內容如下

1 后端接口獲取城市信息

2 先獲取省 根據用戶點擊的省獲取市

3 再根據用戶點擊的市獲取區(qū) 

組件代碼:

<template>
 <div class="city">
 <!-- 點擊此處 省市區(qū)選擇出現 -->
 <div class="chooseCity" @click="clickCity">{{chooseCity}}</div>
 <div class="boxcity" v-if="showCity">
 <!-- 省市區(qū)的標題 點擊可回退 -->
 <div class="chooseTit">
  <p @click="chooseProvince" v-show='tit1'>{{chooseTit1}}</p>
  <p @click="chooseCity2" v-show='tit2'>{{chooseTit2}}</p>
  <p v-show='tit3'>{{chooseTit3}}</p>
 </div>
 <!-- 省市區(qū) -->
 <div class="citys">
 <div @click="getCity" class="province">
  <ul v-show="showProvince">
  <li v-for="item in provinceL" :key="item.regionId" @click="getProvince(item)">{{item.regionName}}</li>
 </ul>
 <ul v-show="showCity2">
  <li v-for="item in cityL" :key="item.regionId" @click="getCity2(item)">{{item.regionName}}</li>
 </ul>
  <ul v-show="showarea">
  <li v-for="item in areaL" :key="item.regionId" @click="getarea(item)">{{item.regionName}}</li>
 </ul>
 </div>
 </div>
 </div>
 <!-- 遮罩層 -->
 <div class="mask" v-show="mackShow" @click="closeMask"></div>
 </div>
</template>
 
<script>
export default {
 data () {
 return {
 chooseCity:"點擊我選擇",
 selected : '',
 citySelected: '',
 areaSelected: '',
 provinceL : [],
 cityL : [],
 areaL : [],
 city : [],
 provinceName: '',
 cityName : '',
 areaName : '',
 showProvince:true,
 showCity:false,
 showCity2:false,
 showarea:false,
 chooseTit1:"省",
 chooseTit2:"市",
 chooseTit3:"區(qū)",
 tit1:true,
 tit2:false,
 tit3:false,
 mackShow:false,
 province:"",
 Nextcity:"",
 district:"",
 totalCity:"",
}
 },
 methods:{
 //點擊省市標題隱藏出現內容 形成回退效果
 chooseProvince(){
 this.showProvince = true;
 this.showCity2 = false;
 },
 chooseCity2(){
 this.showProvince = false;
 this.showCity2 = true;
 this.showarea = false;
 },
 //點擊省市區(qū)出現
 clickCity(){
 this.showCity = true;
 this.mackShow = true;
 },
 //點擊省市區(qū) 讓每個li內展示的名字等于數據的城市名
 getCity(){
 for(var item of this.provinceL){
  this.provinceName = item.regionName;
  //this.regionId = item.regionId
 }
 },
 //當用戶點擊某個省事件 根據省的id獲取市
 getProvince(item){
 this.province = item.regionName
 console.log(this.province);
 // console.log(item.regionId);
 this.$axios({
 url:'http://192.168.1.16:0000/insurance-intact-wechat-api/get_regions?parentId='+item.regionId,
 method: 'get'
 }).then(res=>{
 //console.log(res)
  this.cityL = res.data;
  this.citySelected = this.cityL[0].regionId;
  this.showProvince = false;
  this.showCity2= true;
  this.tit2 = true;
 })
 
 this.areaL = [];
 
 },
 //當用戶點擊某個市事件 根據省的id獲取區(qū)
 getCity2(item){
 this.Nextcity = item.regionName
 console.log(this.Nextcity);
 // console.log(item.regionId);
 this.$axios({
 url:'http://192.168.1.16:0000/insurance-intact-wechat-api/get_regions?parentId='+item.regionId, 
 method: 'get'
 }).then(res=>{
 //console.log(res)
  this.areaL = res.data;
  this.areaSelected = this.areaL[0].regionId;
  this.showarea = true;
  this.showCity2= false;
  this.tit3 = true;
 })
 },
 //用戶點擊區(qū)或者鎮(zhèn),遮罩消失
 getarea(item){
 this.district = item.regionName;
 console.log(this.district);
 var totalCity = this.province+"," + this.Nextcity +"," +this.district;
 this.chooseCity =totalCity;
 //console.log(item.regionId);
 this.showCity = false;
 this.mackShow = false;
 },
 
 closeMask(){
 this.showCity = false;
 this.mackShow = false;
 }
 },
 //頁面初始化 請求數據 將請求到的城市保存下來
 created() {
  var url="http://192.168.1.16:0000/insurance-intact-wechat-api/get_regions?parentId=0";
   this.$axios({
   method:'get',
   url:url,
   withCredentials: true,
   crossDomain: true,
   data:"data",
   headers: {
    'Content-Type':'application/x-www-form-urlencoded',
   }
   }).then(res=>{
   //console.log(res.data);
   this.provinceL = res.data;
   
 
   })
   .catch(error=>{
   console.log(error);
  });
 },
}
</script>
 
<style scoped>
 .chooseCity{
 width: 100%;
 height: 40px;
 text-align: center;
 line-height: 40px;
 border-bottom: 1px solid #666;
 }
 .boxcity{
 position: absolute;
 width: 40%;
 right: 0;
 top:0;
 height: 60%;
 z-index: 100;
 background: #ffffff;
 }
 .citys{
 border-top: 1px solid #666; 
 height: 100%;
 overflow: hidden;
 overflow-y: scroll;
 background: #ffffff;
 }
 .province{
 height: 100%;
 }
 /* 讓滾動條不顯示 */
 .citys::-webkit-scrollbar {
 display: none;
 }
 ul{
 margin:0;
 padding:0;
 }
li{
 list-style: none;
 margin-top: 10px;
}
.chooseTit {
 display: flex;
 justify-content: space-around;
 width: 100%;
 text-align: center;
 background: #448ff7;
}
.chooseTit p{
 color: #ffffff;
}
.mask{
 position: absolute;
 width: 100%;
 height: 100%;
 background: black;
 opacity: .5;
 top:0;
 left: 0;
 z-index: 90;
}
</style>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Electron-vue開發(fā)的客戶端支付收款工具的實現

    Electron-vue開發(fā)的客戶端支付收款工具的實現

    這篇文章主要介紹了Electron-vue開發(fā)的客戶端支付收款工具的實現,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-05-05
  • Vue實現生成本地Json文件功能方式

    Vue實現生成本地Json文件功能方式

    這篇文章主要介紹了Vue實現生成本地Json文件功能方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • 淺談vue中關于checkbox數據綁定v-model指令的個人理解

    淺談vue中關于checkbox數據綁定v-model指令的個人理解

    這篇文章主要介紹了淺談vue中關于checkbox數據綁定v-model指令的個人理解,v-model用于表單的數據綁定很常見,下面就來詳細的介紹一下
    2018-11-11
  • 詳解vue表單驗證組件 v-verify-plugin

    詳解vue表單驗證組件 v-verify-plugin

    本篇文章主要介紹了詳解vue表單驗證組件 v-verify-plugin,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • 用vue快速開發(fā)app的腳手架工具

    用vue快速開發(fā)app的腳手架工具

    這篇文章主要介紹了用vue快速開發(fā)app的腳手架工具,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-06-06
  • Vue.js實現圖片的隨意拖動方法

    Vue.js實現圖片的隨意拖動方法

    下面小編就為大家分享一篇Vue.js實現圖片的隨意拖動方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • vue 動態(tài)修改a標簽的樣式的方法

    vue 動態(tài)修改a標簽的樣式的方法

    這篇文章主要介紹了vue 動態(tài)修改a標簽的樣式的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-01
  • vue單文件組件的實現

    vue單文件組件的實現

    最近翻閱了一下vue。發(fā)覺有一個單文件組件之前基本忽視掉了。所以本文就詳細的介紹了vue單文件組件的實現,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-06-06
  • Vue.js組件通信之自定義事件詳解

    Vue.js組件通信之自定義事件詳解

    這篇文章主要為大家詳細介紹了Vue.js組件通信之自定義事件,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-10-10
  • vxe-table?實現?excel?選擇一個單元格拖拽自動復制新的單元格(示例代碼)

    vxe-table?實現?excel?選擇一個單元格拖拽自動復制新的單元格(示例代碼)

    vxe-table是一款強大的表格組件,支持Excel風格的操作,通過鼠標右下角的擴展按鈕,用戶可以拖拽選擇單元格并自動復制內容到擴展區(qū)域的所有單元格中,本文通過示例代碼給大家介紹的非常詳細,感興趣的朋友一起看看吧
    2025-01-01

最新評論

吉木萨尔县| 浦北县| 三江| 隆德县| 阜南县| 永善县| 鲁甸县| 延庆县| 呼图壁县| 肇东市| 肇州县| 遵化市| 赤峰市| 广宗县| 永寿县| 罗甸县| 唐河县| 大连市| 盐山县| 大荔县| 沈丘县| 龙井市| 兴国县| 玉屏| 灵丘县| 德江县| 辽阳市| 腾冲县| 盖州市| 清镇市| 抚远县| 六枝特区| 金寨县| 察隅县| 和龙市| 延津县| 巴青县| 左云县| 南丰县| 那坡县| 长泰县|