fix: 无法立即显示时间

This commit is contained in:
imsyy 2023-07-26 14:51:16 +08:00
parent 9d2290d694
commit b9f9e5d527
2 changed files with 10 additions and 9 deletions

View File

@ -1,16 +1,13 @@
<template>
<div
class="weather"
v-if="weatherData.adCode.city && weatherData.weather.weather"
>
<div class="weather" v-if="weatherData.adCode.city && weatherData.weather.weather">
<span>{{ weatherData.adCode.city }}&nbsp;</span>
<span>{{ weatherData.weather.weather }}&nbsp;</span>
<span>{{ weatherData.weather.temperature }}</span>
<span class="sm-hidden">
&nbsp;{{
weatherData.weather.winddirection?.endsWith("风")
? weatherData.weather.winddirection
: weatherData.weather.winddirection + "风"
? weatherData.weather.winddirection
: weatherData.weather.winddirection + "风"
}}&nbsp;
</span>
<span class="sm-hidden">{{ weatherData.weather.windpower }}&nbsp;</span>

View File

@ -46,10 +46,14 @@ const store = mainStore();
const currentTime = ref({});
const timeInterval = ref(null);
//
const updateTimeData = () => {
currentTime.value = getCurrentTime();
};
onMounted(() => {
timeInterval.value = setInterval(() => {
currentTime.value = getCurrentTime();
}, 1000);
updateTimeData();
timeInterval.value = setInterval(updateTimeData, 1000);
});
onBeforeUnmount(() => {