温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么在微信小程序中实现一个滑动翻页效果

发布时间:2021-04-17 16:17:20 阅读:1215 作者:Leah 栏目:web开发
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章将为大家详细讲解有关怎么在微信小程序中实现一个滑动翻页效果,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

<view class="mainFrame">
 <swiper class="container" indicator-dots="{{indicatorDots}}" indicator-dots="{{indicatordots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
  <block wx:for="{{xinwen_list}}" wx:for-index="index">
   <swiper-item class="vol-swiper-item" bindtap="onItemClick">
    <view class="vol-meta-title">
     <image class="icon_right" src="../../image/左.png"></image>
     <text class="vol-number">来源:{{item.copyfrom}}</text>
     <image class="icon_left" src="../../image/右.png"></image>
    </view>
    <view class="vol-card" data-id="{{item.id}}" catchtap="onPostTap">
     <!--<view data-detail-href="{{item.detailHref}}" rel="external nofollow" class="item">-->
     <!--图片-->
     <image class="vol-picture" src="{{item.images[0]}}" mode="aspectFill"></image>
     <!--标题-->
     <view class="vol-meta-title">
      <text class="vol-number">{{item.title}}</text>
     </view>
     <!--时间-->
     <view class="vol-meta-time">
      <text>{{item.inputtime}}</text>
     </view>
     <!--描述信息-->
     <view class="vol-content">
      <text class="vol-content-text">{{item.description}}</text>
     </view>
     <!--</view>-->
    </view>
   </swiper-item>
  </block>
 </swiper>
</view>
<loading hidden="{{hidden}}" bindchange="loadingChange">
 加载中...
</loading>

js

var Api = require("../../utils/api.js")
var ARR_NEWS_DATA=[]
Page({
 data: {
  hiddenfalse,
  xinwen_list: [],
  indicatorDotsfalse,
  autoplayfalse,
  interval2000,
  indicatordotstrue,
  duration1000
 },
 onLoad: function () {
  var that = this;
  var videoUrl = Api.Url + "&isvideo=1"
  Api.fetchGet(videoUrl, (err, res) => {
   for (var i = 0; i < 14; i++) {
    res.data[i].inputtime = Api.js_date_time(res.data[i].inputtime)
    ARR_NEWS_DATA.push(res.data[i])
   }
   that.setData({
    hiddentrue,
    xinwen_list: ARR_NEWS_DATA,
   })
  })
 },
 onPostTap: function (event{
  var postId = event.currentTarget.dataset.id;
  wx.navigateTo({
   url"../video/video-listdetails?id=" + postId
  })
 },
 onShareAppMessage: function ({
  return {
   title: '柳州1号+ 视听页面',
   path: 'pages/video/video'
  }
 }
})

css

.mainFrame {
 margin-top0rpx;
 height100%;
 display: flex;
 flex-direction: column;
 border0px solid #ebebeb;
}
.container {
height1135rpx;
 padding-top0px;
background#b3d4db
}
.icon_right{
 height30px;
 width30px;
  padding-right60rpx;
}
.icon_left{
  height30px;
 width30px;
  padding-left60rpx;
}
.vol-swiper-item {
 box-sizing: border-box;
 padding-left30rpx;
 padding-right30rpx;
}
.title {
 display: block;
 width100%;
 height50px;
 color#f00;
}
.time {
 font-size22rpx;
 text-align: right;
 color#ccc;
}
.vol-card {
 /*parent layout and this inner padding*/
 padding20rpx;
 height965rpx;
 border2px solid #ebebeb;
 border-radius5px;
 box-shadow5px 5px 5px #c0c0c0;
 background#fff;
 margin-top0px;
}
.vol-swiper {
 height100%;
}
.vol-picture {
 width100%;
}
.vol-meta-title {
 margin-top5px;
 text-align: center;
 padding10rpx 5rpx;
 font-size17px;
 color#000;
 font-family'KaiTi';
}
.vol-meta-time {
 padding10rpx 5rpx;
 font-size12px;
 padding-right5px;
 color#888;
}
.vol-content {
 margin-top15rpx;
 padding0 5rpx;
 font-size14px;
 line-height1.4;
 font-family'KaiTi';
 color#9c9c9c;
}
.vol-content-text {
 margin-top5px;
 width100%;
 min-height200rpx;
 display: inline-block;
 text-indent2em;
}
.vol-makettime {
 font-size13px;
 color#888;
 text-align: right;
}

关于怎么在微信小程序中实现一个滑动翻页效果就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×