console
new Vue({
el:'#app',
data:{
city:'上海',
weatherList:[]
},
methods:{
searchWeather:function(){
var that=this;
axios.get('http://wthrcdn.etouch.cn/weather_mini?city='+this.city)
.then(function(response){that.weatherList=response.data.data.forecast;})
.catch(function(err){console.log('err')})
}
}
})
<div id='app'>
<div class='top'>
<input type='text' v-model='city' @keyup.Enter='searchWeather'>
<button>搜索</button>
</div>
<div class='bottom'>
<ul>
<li v-for='(item,index) in weatherList' :class="[index==4?'end':'']">
<h2>{{item.type}}</h2><br>
<h6>{{item.high}}-{{item.low}}</h6><br>
<h4>{{item.date}}</h4>
</li>
</ul>
</div>
</div>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
*{
margin:0;
padding:0;
}
li{
display:block;
float:left;
margin-left:10px;
}
.end{
background-color:red;
}