修改bug
This commit is contained in:
@@ -40,11 +40,14 @@ export default {
|
||||
};
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
;this.getTimes()
|
||||
this.getWeather()
|
||||
mounted() {
|
||||
this.getTimes()
|
||||
this.weatherInterval = setInterval(() => {
|
||||
this,this.getWeather()
|
||||
}, 1000)
|
||||
},
|
||||
destroyed() {
|
||||
// console.log(1111)
|
||||
clearInterval(this.weatherInterval)
|
||||
},
|
||||
methods: {
|
||||
@@ -87,23 +90,21 @@ export default {
|
||||
'.' +
|
||||
day
|
||||
},
|
||||
async getWeather() {
|
||||
this.weatherInterval = setInterval(() => {
|
||||
fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=a20a2093715deb9bd68e423c34a2ac3c&city=110108`, {
|
||||
method: 'get',
|
||||
extensions: 'base',
|
||||
getWeather() {
|
||||
fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=a20a2093715deb9bd68e423c34a2ac3c&city=110108`, {
|
||||
method: 'get',
|
||||
extensions: 'base',
|
||||
// output:'JSON'
|
||||
}).then((response) => {
|
||||
// 注意此处
|
||||
response.json().then((data) => {
|
||||
console.log(data)
|
||||
this.weather = data.lives[0].weather + ' '+ data.lives[0].temperature + '℃'
|
||||
}).catch((err) => {
|
||||
}).then((response) => {
|
||||
// 注意此处
|
||||
response.json().then((data) => {
|
||||
console.log(data)
|
||||
this.weather = data.lives[0].weather + ' ' + data.lives[0].temperature + '℃'
|
||||
}).catch((err) => {
|
||||
this.weather = '晴 25℃'
|
||||
console.log(err);
|
||||
})
|
||||
})
|
||||
}, 1000)
|
||||
console.log(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
toggleFullscreen() {
|
||||
screenfull.toggle();
|
||||
|
||||
Reference in New Issue
Block a user