1. 程式人生 > >vue實現二級聯動效果

vue實現二級聯動效果

區域 紐約 select doctype use sel height www over

你如城市與省份間的二級聯動效果

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>demo</title>
	<style type="text/css">
		.pag-set-bg{width:100%;height:100%;overflow-x:hidden;overflow-y:auto;}
	</style>
</head>
<body>
<div id="app">
	<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"></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"></use>
              </svg>
            </option>
          </select>
        </div>
</div>
<script type="text/javascript" src="../../js/jquery_v3.3.1.js"></script>
<script src="../../js/vue.js"></script>
<script src="../../js/vue-resource.min.js"></script>
<script>
	new Vue({
		el:‘#app‘,
		data:{
			list:[
				{
		          text: ‘這是第1條數據‘
		        }
			],
			UniversityList:[],
        	schoolList:[],
        	countryName:{},
	        cityName:"請選擇城市",
	        area:[
	          {
	            "country":"美國",
	            "city":[
	              "紐約",
	              "洛杉磯",
	              "舊金山",
	              "西雅圖",
	              "波士頓",
	              "休斯頓",
	              "聖地亞哥",
	              "芝加哥",
	              "其它",
	            ]
	          },
	          {
	            "country":"加拿大",
	            "city":[
	              "溫哥華",
	              "多倫多",
	              "蒙特利爾",
	              "其它"
	            ]
	          },
	          {
	            "country":"澳大利亞",
	            "city":[
	              "悉尼",
	              "墨爾本",
	              "其它"
	            ]
	          },
	          {
	            "country":"新加坡",
	            "city":[
	              "新加坡"
	            ]
	          },
	         
	        ],
		},
		
		methods:{
		      selectCountry(value){
		        this.cityName=this.countryName.city[0];
		      },
			}
		})
</script>
</body>
</html>

  http://www.cnblogs.com/beileixinqing/p/8252153.html

vue實現二級聯動效果