46 lines
1023 B
HTML
46 lines
1023 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Vue 天气预报</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.1"></script>
|
|
</head>
|
|
<body>
|
|
<div id="app">
|
|
<ul>
|
|
<li v-for="item in futureList">{{item.temperature}}</li>
|
|
</ul>
|
|
</div>
|
|
<script>
|
|
|
|
//
|
|
new Vue({
|
|
el: '#app',
|
|
mounted() {
|
|
this.getData()
|
|
},
|
|
data:{
|
|
ajaxUrl : 'http://103.91.219.160:3000/getWeather',
|
|
futureList: []
|
|
},
|
|
methods: {
|
|
getData() {
|
|
this.$http.get(this.ajaxUrl, {
|
|
params: {
|
|
cityname: '合肥'
|
|
}
|
|
})
|
|
.then( function(success) {
|
|
this.futureList = success.data.result.future
|
|
},function(error) {
|
|
console.log(error)
|
|
})
|
|
}
|
|
},
|
|
})
|
|
</script>
|
|
</body>
|
|
</html> |