天气添加风向和风速

main
zhufu 2026-02-03 17:04:21 +08:00
parent 2f5d6b524c
commit 00f8f91f9a
1 changed files with 16 additions and 0 deletions

View File

@ -12,6 +12,8 @@
/>
<span class="text">{{ Weather }} °C</span>
</div>
<div class="wind-speed">
<span style="margin-right: 25px;">{{`风速:${windPower}m/s`}}</span>{{`风向: ${winddirection}`}}</div>
</div>
</template>
@ -38,6 +40,8 @@
const currentTime = ref(dayjs().locale('zh-cn').format('YYYY年M月D日 dddd HH:mm:ss'));
const Weather = ref('');
const windPower = ref()
const winddirection = ref()
async function getWeather() {
try {
//
@ -46,6 +50,8 @@
url: `https://restapi.amap.com/v3/weather/weatherInfo?city=371300&key=ae4fb485fa25f5884b9cd7c1101687c4`,
}).then((res) => {
Weather.value = res.data.lives[0].temperature;
windPower.value = res.data.lives[0].windpower;
winddirection.value = res.data.lives[0].winddirection;
if(res.data.lives[0].weather == '阴'){
weatherIcon.value = "wi:cloud"
}else if(res.data.lives[0].weather == '晴'){
@ -116,5 +122,15 @@
font-size: v-bind('textSize+"px"');
}
}
.wind-speed{
position: absolute;
top: 45px;
left: 30px;
width: 400px;
height: 42px;
margin-left: 10px;
color: v-bind('textColor');
font-size: v-bind('textSize+"px"');
}
</style>