fix: 无法立即显示时间
This commit is contained in:
parent
9d2290d694
commit
b9f9e5d527
@ -1,16 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div class="weather" v-if="weatherData.adCode.city && weatherData.weather.weather">
|
||||||
class="weather"
|
|
||||||
v-if="weatherData.adCode.city && weatherData.weather.weather"
|
|
||||||
>
|
|
||||||
<span>{{ weatherData.adCode.city }} </span>
|
<span>{{ weatherData.adCode.city }} </span>
|
||||||
<span>{{ weatherData.weather.weather }} </span>
|
<span>{{ weatherData.weather.weather }} </span>
|
||||||
<span>{{ weatherData.weather.temperature }}℃</span>
|
<span>{{ weatherData.weather.temperature }}℃</span>
|
||||||
<span class="sm-hidden">
|
<span class="sm-hidden">
|
||||||
{{
|
{{
|
||||||
weatherData.weather.winddirection?.endsWith("风")
|
weatherData.weather.winddirection?.endsWith("风")
|
||||||
? weatherData.weather.winddirection
|
? weatherData.weather.winddirection
|
||||||
: weatherData.weather.winddirection + "风"
|
: weatherData.weather.winddirection + "风"
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
<span class="sm-hidden">{{ weatherData.weather.windpower }} 级</span>
|
<span class="sm-hidden">{{ weatherData.weather.windpower }} 级</span>
|
||||||
|
@ -46,10 +46,14 @@ const store = mainStore();
|
|||||||
const currentTime = ref({});
|
const currentTime = ref({});
|
||||||
const timeInterval = ref(null);
|
const timeInterval = ref(null);
|
||||||
|
|
||||||
|
// 更新时间
|
||||||
|
const updateTimeData = () => {
|
||||||
|
currentTime.value = getCurrentTime();
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
timeInterval.value = setInterval(() => {
|
updateTimeData();
|
||||||
currentTime.value = getCurrentTime();
|
timeInterval.value = setInterval(updateTimeData, 1000);
|
||||||
}, 1000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user