1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| var tianqi = new Vue({ el:"#tianqi", data:{ city:"", weatherlist:[] }, methods:{ searchWeather:function(){ var that = this; axios.get("http://wthrcdn.etouch.cn/weather_mini?city="+this.city) .then(function(response){ console.log(response.data.data.forecast) that.weatherlist=response.data.data.forecast; }) .catch(function(err){ alert("城市输入错误") }) }, changecity:function(cityin){ this.city=cityin; this.searchWeather(); } } })
|