vue实现天气查询


效果如下:

 

 支持回车查询和点击查询,使用axios调用http://wthrcdn.etouch.cn/weather_mini接口

js代码如下

var app = 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){
               
               console.log(response.data.data.forecast);
               that.weatherList = response.data.data.forecast
           })
           .catch(function(err){})
        }
    },
})
View Code

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM