微信小程序学习第三章--实战(滚动视图)

本文档介绍了微信小程序中滚动视图的实战应用,包括配置app.json、编写home.wxml、wxss和js文件以实现轮播图、下拉刷新和上拉加载功能。在实践过程中遇到横向滑动问题,解决办法是为组件添加view隔层,并调整样式高度宽度。此外,还提供了参考项目链接供进一步学习。
摘要由CSDN通过智能技术生成

一、参考文档

https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
在这里插入图片描述

二、项目实战

先修改app.json

{
  "pages":[
    "pages/home/home"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#ffba1e",
    "navigationBarTitleText": "高仿糗事百科",
    "navigationBarTextStyle":"black"
  },
  "style": "v2",
  "sitemapLocation": "sitemap.json"
}

home.wxml(这里实现了轮播图以及滚动视图)

<!--pages/home/home.wxml-->
<view>
  <view class="navTop">
    <scroll-view class="topTitle" scroll-x="true">
      <view class="top">
        <view>
          <view id='0' class="{
  {currentPage==0? 'selected':'normal'}}" bindtap="changeTopic">VIP专享</view>
          </view>
        <view>
          <view id='1' class="{
  {currentPage==1? 'selected':'normal'}}" bindtap="changeTopic">视频</view>
          </view>
        <view>
          <view id='2' class="{
  {currentPage==2? 'selected':'normal'}}" bindtap="changeTopic">图片</view>
        </view>
        <view>
          <view id='3' class="{
  {currentPage==3? 'selected':'normal'}}" bindtap="changeTopic">糗事</view>
        </view>
        <view>
          <view id='4' class="{
  {currentPage==4? 'selected':'normal'}}" bindtap="changeTopic">精华</view>
        </view>
        <view>
          <view id='5' class="{
  {currentPage==5? 'selected':'normal'}}" bindtap="changeTopic">穿越</view>
        </view>
        <view>
          <view id='6' class="{
  {currentPage==6? 'selected':'normal'}}" bindtap="changeTopic">爆料</view>
        </view>      
      </view>
    </scroll-view>

    <view class="opr">
      审核
    </view>
    <view class="add">
      +
    </view>
  </view>
  
  <swiper style="height:{
  {pageHeight}}rpx" current="{
  {currentPage}}">
    <swiper-item>
      <include src="/pages/home/vip.wxml"/>
    </swiper-item>

    <swiper-item>
      <view><include src='./video.wxml' />
      </view>
    </swiper-item>

    <swiper-item>
      <view>
      <include src='image.wxml'/>
      </view>
    </swiper-item>

    <swiper-item>
      <view>糗事</view>
    </swiper-item>

    <swiper-item>
      <view>精华</view>
    </swiper-item>

    <swiper-item>
      <view>穿越</view>
    </swiper-item>

    <swiper-item>
      <view>爆料</view>
    </swiper-item>

  </swiper>
</view>

home.wxss

.navTop{
  display: flex;
  flex-direction: row;
  background-color: darkorange;
}

/* 如果要设置不全部都占用,那么就在原有基础上继续加东西 */
.topTitle{
  height: 110rpx;
  width: 75%;  
}

.top{
  display: flex;
  flex-direction: row;
  margin-top: 20rpx;
  margin-left: 20rpx;
}

.selected
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值