zoukankan      html  css  js  c++  java
  • 小程序 swiper 内容自适应

    js 
     
    get_wxml: function (className, callback) {
    wx.createSelectorQuery().selectAll(className).boundingClientRect(callback).exec()
    },
     
    //获取节点信息
    this.get_wxml(`#cont` + current, (rects) => {
    console.log(rects)
    let newHeight = rects[0].height
    this.setData({
    heights: newHeight 
    })
    })
     
    xml 
     
    <view class="goods_info_box">
    <view class="tba_contain">
    <!-- 导航栏 -->
    <scroll-view class="tab" scroll-x scroll-left="{{tabScroll}}" scroll-with-animation="true">
    <block wx:for="{{menuList}}" wx:key="index">
    <view class="tab-item {{currentTab == index ? 'active' : ''}}" data-current="{{index}}" bindtap='clickMenu' style="{{100/menuList.length}}%">
    <text>{{item.name}}</text>
    </view>
    </block>
    </scroll-view>
    <!-- 页面 -->
    <swiper class="list_content" duration="500" current="{{currentTab}}" bindchange="changeContent" style="height:{{heights}}px">
    <swiper-item class="content-item" wx:for="{{menuList}}" wx:key="index" >
    <view >
    <text class='reason_txt'> {{item.name}}</text>
    </view>
    <view id='cont{{index}}' class="swiper-com" style="color:#000;font-size:40rpx;">
    <rich-text nodes="{{item.content}}" ></rich-text>
    </view>
    </swiper-item>
    </swiper>
    </view>
    </view>
     
    有问题欢迎留言
  • 相关阅读:
    js对象
    实习经历日志02
    前端实习经历日志01
    js变量提升
    WebApls-元素(offset, client, scroll)
    WebApls-Bom
    WebApls-DOM的核心总结
    WebApls-节点01
    javascript-
    Javascript-字符串对象
  • 原文地址:https://www.cnblogs.com/corvus/p/12705142.html
Copyright © 2011-2022 走看看