i229194964
@i229194964
Веб разработчик

Есть прилржение о погоде проблема показывает два -- место одной почему?

показывает
Moscow
Температура: -13°--9° C

Описание: broken clouds

Weather Icon
Ulan-Ude
Температура: -19°--19° C

Описание: smoke

Weather Icon
Seoul
Температура: +5°-+7° C

Описание: few clouds
WeatherCard.vue
<template>
  <div class="weather-card">
    <h2>{{ name }}</h2>
    <p v-if="temperatureMin !== null && temperatureMax !== null">
      Температура: {{ formatTemperature(temperatureMin) }}°-{{ formatTemperature(temperatureMax) }}° {{ unit }}
    </p>
    <p v-else>Температура недоступна</p>
    <p>Описание: {{ description }}</p>
    <img :src="getWeatherIconUrl(icon)" alt="Weather Icon" class="weather-icon">
  </div>
</template>

<script>
export default {
  props: {
    name: String,
    temperatureMin: Number,
    temperatureMax: Number,
    description: String,
    icon: String,
    unit: String,
  },
  methods: {
    formatTemperature(temperature) {
      if (temperature !== null && typeof temperature === 'number') {
        const roundedTemp = Math.round(temperature);
        return `${roundedTemp >= 0 ? '+' : ''}${roundedTemp}`;
      } else {
        return "Недоступно";
      }
    },
    getWeatherIconUrl(icon) {
      if (icon && icon !== "") {
        return `http://openweathermap.org/img/w/${icon}.png`;
      } else {
        return 'http://openweathermap.org/img/w/unknown.png';
      }
    },
  },
};
</script>

<style scoped>
.weather-card {
  border: 1px solid #ccc;
  padding: 10px;
  margin: 10px;
  width: 200px;
  text-align: left;
  display: inline-block;
}

.weather-icon {
  max-width: 50px;
}
</style>
  • Вопрос задан
  • 55 просмотров
Решения вопроса 1
yarkov
@yarkov Куратор тега Vue.js
Помог ответ? Отметь решением.
Почему?

}}°-{{
   ^
Потому
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы