day06微信小程序项目API讲解

博主继续编写天气预报小程序,老师检查作业后指出多数同学页面文字堆叠、不美观且繁杂。要求做出导航栏顶部搜索栏实现各地天气查询,做出左右滑动框查看实时天气。博主上网搜索示例代码借鉴方法和语句,还涉及输入框搜索功能、滚动栏编写及功能预览。

今天继续编写天气预报这个小程序,老师检查了我们提交的作业,发现大多数同学做出来的页面都是把文字堆叠在一起,虽然实现了天气查询的功能,但是界面看起来不美观,且内容繁杂。所以今天老师要求我们做出导航栏顶部的搜索栏,实现各地天气的查询;并作出左右滑动的框,实现左右滑动查看实时天气情况。因为数据内容众多,上网搜索相关天气预报小程序的示例代码,我借鉴了其中的方法及语句。

输入框搜索功能

编写.js文件

 // 输入框搜索功能
  finish:function(e){
    var _this = this;
    // console.log(e.detail.value);
    _this.setData({
      location: e.detail.value
    })
    this.getWeather(_this);
  },

编写.wxml文件

 <input class='ipt' placeholder-class='pla' placeholder='请输入城市名,快速查询天气信息' bindconfirm="finish" ></input>

滚动栏的编写

编写.wxml文件

 <view class='guide' wx:if='{{cityDatas.daily_forecast}}'>
      <view class='title'>7 天预报</view>
      <view class='guides'>
        <view class='item' wx:for='{{cityDatas.daily_forecast}}' wx:key='{{index}}'>
          <view class='date i'>{{item.date}}</view>
          <view class='temperature i'>{{item.tmp_max}}~{{item.tmp_min}}℃</view>
          <view class='weather i'>
            <text>{{item.cond_txt_d}}</text>
            <image mode='widthFix' src='{{weatherIconUrl}}{{item.cond_code_d}}.png'></image>
          </view>
          <view class='wind i'>{{item.wind_dir}}{{item.wind_sc}}级</view>
        </view>
      </view>
    </view>
    <view class='details'>
      <view class='detail' wx:for='{{detailsDic.key}}' wx:key='{{index}}'>
        <view>{{detailsDic.val[item]}}</view>
        <view>{{cityDatas.now[item]}}</view>
      </view>
    </view>
    <view class='hourly' wx:if='{{hourlyDatas.length}}'>
      <view class='title'>24 小时逐 3 小时预报</view>
      <view class='hours'>
        <swiper style='height:360rpx;' indicator-dots="{{false}}" autoplay="{{false}}" circular="{{false}}" duration="300" next-margin="50rpx">
          <block wx:for="{{hourlyDatas}}" wx:key="{{index}}">
            <swiper-item>

功能预览

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值