小程序swiper怎么根据页面长度滑动


小程序swiper根据页面长度滑动的案例:

在对应的js文件中添加以下代码:

get_wxml:function(className,callback){

wx.createSelectorQuery().selectAll(className).boundingClientRect(callback).exec()

},

//获取节点信息

this.get_wxml(`#cont`+current,(rects)=>{

console.log(rects)

letnewHeight=rects[0].height

this.setData({

heights:newHeight

})

})

在对应的wxml文件中添加以下代码:

<viewclass="goods_info_box">

<viewclass="tba_contain">

<!--导航栏-->

<scroll-viewclass="tab"scroll-xscroll-left="{{tabScroll}}"scroll-with-animation="true">

<blockwx:for="{{menuList}}"wx:key="index">

<viewclass="tab-item{{currentTab==index?'active':''}}"data-current="{{index}}"bindtap='clickMenu'style="width:{{100/menuList.length}}%">

<text>{{item.name}}</text>

</view>

</block>

</scroll-view>

<!--页面-->

<swiperclass="list_content"duration="500"current="{{currentTab}}"bindchange="changeContent"style="height:{{heights}}px">

<swiper-itemclass="content-item"wx:for="{{menuList}}"wx:key="index">

<view>

<textclass='reason_txt'>{{item.name}}</text>

</view>

<viewid='cont{{index}}'class="swiper-com"style="color:#000;font-size:40rpx;">

<rich-textnodes="{{item.content}}"></rich-text>

</view>

</swiper-item>

</swiper>

</view>

</view>


上一篇:mysql和db2的区别有哪些

下一篇:微信小程序怎么设置首页页面


小程序 小程序页面 swiper
Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器