基于Vue3+Vite实现的移动端天气预报系统
<template>
<div class="weather-app">
<weather-search @getWeather="getWeather" />
<weather-detail v-if="weatherInfo" :weatherInfo="weatherInfo" />
</div>
</template>
<script>
import { ref } from 'vue';
import WeatherSearch from './components/WeatherSearch.vue';
import WeatherDetail from './components/WeatherDetail.vue';
export default {
name: 'App',
components: {
WeatherSearch,
WeatherDetail
},
setup() {
const weatherInfo = ref(null);
const getWeather = (weatherData) => {
weatherInfo.value = weatherData;
};
return {
weatherInfo,
getWeather
};
}
};
</script>
<style>
.weather-app {
max-width: 400px;
margin: 0 auto;
padding: 20px;
}
</style>
这个简单的Vue应用展示了如何在Vue 3和Vite环境中创建一个用户可以查询天气并显示详细信息的应用。它包括一个搜索组件和一个显示天气详情的组件。应用的样式也非常简洁,适合移动端显示。
评论已关闭