微信小程序Slideview和cell

微信小程序Slideview和cell的用法和使用:

提示:左滑删除组件,基础库 2.4.4 开始支持:


使用方法:

微信UI扩展组件库基于小程序自定义组件构建,在使用扩展组件库之前要在全局json中引入扩展库.
(1)这里我们通过 useExtendedLib 扩展库 的方式引入,这种方式引入的组件将不会计入代码包大小

{
    
    
  "useExtendedLib": {
    
    
    "kbone": true,
    "weui": true
  }
}
(2)然后就可以在 页面.json 中引入模块组件(和自定义组件一样):
{
    
    
  "usingComponents": {
    
    
    "mp-slideview": "weui-miniprogram/slideview/slideview",
    "mp-cells": "weui-miniprogram/cells/cells",
    "mp-cell": "weui-miniprogram/cell/cell"
  }
}
(3)然后在 页面.wxml 中写入模块:
<mp-slideview buttons="{
    
    {slideButtons}}" bindbuttontap="slideButtonTap">
  <mp-cell >
    <view slot="icon">左侧图标</view>
    <view slot="">内容</view>
    <view slot="footer">右侧区域slot</view>
  </mp-cell>
</mp-slideview>
(4)最后在 页面.js中写入配置:
Page({
    
    
    onLoad: function(){
    
    
        this.setData({
    
    
            slideButtons: [{
    
    
              text: '普通',
            },{
    
    
              text: '普通',
              extClass: 'test',
            },{
    
    
              type: 'warn',
              text: '警示',
              extClass: 'test',
            }],
        });
    },
    slideButtonTap(e) {
    
    
        console.log('slide button tap', e.detail)
    }
});
最后这是效果图:

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

猜你喜欢

转载自blog.csdn.net/qq_25846091/article/details/113105079