20 lines
484 B
JavaScript
20 lines
484 B
JavaScript
|
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);
|
||
|
}
|
||
|
})
|
||
|
}
|