lanan-repair/utils/Weather.js

20 lines
484 B
JavaScript
Raw Permalink Normal View History

2024-09-22 15:07:01 +08:00
function getWeather(city){
uni.request({
url: 'https://restapi.amap.com/v3/weather/weatherInfo',
data: {
key: '10fbc0a1e5490c06278eff3a10f0af50',
city: city
},
success: (res) => {
if (res.statusCode == 200) {
let weatherData = res.data;
// 将数据渲染到页面上
} else {
console.log('获取天气信息失败');
}
},
fail: (err) => {
console.log('获取天气信息失败', err);
}
})
}