The realization of WeChat Mini Programs's classified switching

WeChat Mini Programs does the commodity classification switch: click the category to switch to the corresponding category of goods. The effect is as follows

clipboard.png

Classification page category.wxml

  <!--  -->
    <view class="left-box">
    <block wx:for="{{category}}" wx:key="id">
      <view class="menu-item" bindtap="cateTab"  data-index="{{index}}" data-id="{{item.id}}">{{item.name}}</view>
    </block>
    </view>
  <!--  -->
    <view class="right-box}">
      <view class="foods-type-box">
      //,cateData
        <template is="categorydetail" data="{{cateData}}"/>
      </view> 
    </view>
  </view>

switch the interface address of the bound js method
call: http://xxx.com/category/id (which category id decides to call)

// 
  cateTab:function(event){
    var index=event.currentTarget.dataset.index;
    this.cateid=event.currentTarget.dataset.id;
    //id,
    wx.request({
      url: ":http://xxx.com/category/"+this.cateid,
      success: function(res) {
        this.setData({
            cateData:res
        });
      }
    })
    
  },

how to succinctly switch categories and load related items. Please br < God > my above code does not seem to be able to achieve real-time changes, how to modify

Mar.24,2021

you can't write it this way. Using scroll-view and scroll-into-view, has a similar effect. Then you can take a look at
portal

.
Menu