国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue select二級聯動第二級默認選中第一個option值的實例

2024-05-06 15:22:45
字體:
來源:轉載
供稿:網友

當二級聯動比如選擇國家的時候,希望選中一個國家的時候后面城市默認選中第一個城市,則給國家的select加一個@change事件就可以了

<div class="inputLine">  <span>所在區域</span>  <select name="" v-model="countryName" @change="selectCountry">  <option :value="item" v-for="(item,index) in area">  {{item.country}}  <svg class="icon icon-arrow-bottom" aria-hidden="true">  <use xlink:href="#icon-arrow-bottom" rel="external nofollow" rel="external nofollow" ></use>  </svg>  </option>  </select>  <select name="" v-model="cityName">  <option :value="item" v-for="(item,index) in countryName.city">  {{item}}  <svg class="icon icon-arrow-bottom" aria-hidden="true">  <use xlink:href="#icon-arrow-bottom" rel="external nofollow" rel="external nofollow" ></use>  </svg>  </option>  </select> </div>
data  countryName:{},  cityName:"請選擇城市",  area:[   {   "country":"美國",   "city":[    "紐約",    "洛杉磯",    "舊金山",    "西雅圖",    "波士頓",    "休斯頓",    "圣地亞哥",    "芝加哥",    "其它",   ]   },   {   "country":"加拿大",   "city":[    "溫哥華",    "多倫多",    "蒙特利爾",    "其它"   ]   },   {   "country":"澳大利亞",   "city":[    "悉尼",    "墨爾本",    "其它"   ]   },   {   "country":"新加坡",   "city":[    "新加坡"   ]   },   /*{   "country":"中國",   "city":[   "北京市",   ]   },*/  ],

methods:

selectCountry(value){  this.cityName=this.countryName.city[0];  },

以上這篇vue select二級聯動第二級默認選中第一個option值的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 石首市| 读书| 高青县| 米易县| 开阳县| 广宗县| 开江县| 柳江县| 望奎县| 田林县| 分宜县| 常德市| 阿鲁科尔沁旗| 同仁县| 尼勒克县| 英山县| 盖州市| 甘泉县| 东乡族自治县| 扬中市| 宽城| 星子县| 普宁市| 阜康市| 宁明县| 盐池县| 从江县| 石屏县| 苗栗县| 离岛区| 华蓥市| 特克斯县| 旺苍县| 新泰市| 迭部县| 兰溪市| 廉江市| 云霄县| 云霄县| 固镇县| 穆棱市|