1、创建项目:打开微信开发者工具创建项目
2:引用天气接口:打开这个链接找到天气API接口:韩小韩Web API接口站 - 免费Web API数据接口调用服务平台

3、打开天气情况API接口:复制下面图中的链接

4、在创建的微信小程序项目中编写代码:
(1):在app.json中:把原本的wenxin换成天气,修改背景颜色:
(2):在index.wxml中写界面代码(其中的城市、天气、温度等用插值语法动态生成):图中的背景图片可以按照自己喜欢的背景图片
<!-- 天气 -->
<view class="heard-container">
<image class="heard-bg" src="/pages/image/1.jpg"></image>
<view class="heard-content">
<view class="heard_1">{ {city}} { {ji}}</view>
<view class="heard_2">{ {weatherList[0].low}} ~ { {weatherList[0].high}}</view>
<view class="heard_3">{ {weatherList[0].type}}</view>


2万+

被折叠的 条评论
为什么被折叠?



