修改bug

This commit is contained in:
‘937886381’
2024-05-13 16:20:37 +08:00
parent 46d7f4cb8a
commit 097bab8241
7 changed files with 493 additions and 106 deletions

View File

@@ -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();