小程序制作分类可滚动区域 scroll-view

效果图:
在这里插入图片描述

classify.wxml

<view class='header'>
  <view class="search">
      <i-icon type="search" i-class='icon'  size="28" color="#959998"/>
  <text>搜索商品或粘贴淘宝标题</text>
  </view>
</view>


 <view class='main'>

  <view class='left'>
    <scroll-view scroll-y="true" style="height:{
  {main}}px" scroll-into-view="true" scroll-with-animation="true">
      <block  wx:for="{
  {cateItems}}" wx:for-list="item">
        <view class="nav_left_items {
  {curNav == item.cate_id ? 'active' : ''}}" bindtap="switchRightTab" data-index="{
  {index}}" data-id="{
  {item.cate_id}}">{
  {item.cate_name}}</view>

      </block>
    </scroll-view>
    </view>
    
    
    <view class="nav_right">
    <!--如果有数据,才遍历项-->
    <scroll-view scroll-y="true"  style="height:{
  {main}}px" scroll-into-view="true" scroll-with-animation="true">
    <view wx:if="{
  {cateItems[curIndex].ishaveChild}}">
      <block wx:for="{
  {cateItems[curIndex].children}}">
        <view class="nav_right_items">
        <!--界面跳转 -->
          <navigator url="../../detail/detail}}">
            <image src="{
  {item.image}}"></image>
            <text>{
  {item.name}}</text>
          </navigator>
        </view>
      </block>
    </view>
    
    <!--如果无数据,则显示数据-->
    <view class="nodata_text" wx:else>该分类暂无数据</view>
    </scroll-view>
  </view>

 </view>



classify.js

// pages/class/class.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    main: 0,
    cateItems: [{
      
      cate_id: 1,
      cate_name: "女装",
      ishaveChild: true,
      children: [
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值