<html>
head>
script src="https://unpkg.com/axios/dist/axios.min.js"></script="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">
</bodydiv id="app">
input type="text" v-model="city" @keyup.enter="getWeathers"button @click>查询buttonbra href="#" @click="changeCity('北京')">北京a="changeCity('武汉')">武汉="changeCity('上海')">上海="changeCity('深圳')">深圳ul>
li v-for="(item,index) in weathers">
{{item.type}} {{item.low}} {{item.high}} {{item.date}}
lidiv
var vue = new Vue({
el: "#app",data: {
city: '',weathers: [],},methods: {
getWeathers: function () {
var that = this
axios.get('http://wthrcdn.etouch.cn/weather_mini?city=' + this.city)
.then(function (response) {
that.weathers = response.data.data.forecast;
},function (err) {
})
},changeCity: function (city) {
this.city = city;
this.getWeathers();
},})
>