微信小程序使用weui扩展组件index-list

效果展示

在这里插入图片描述

demo地址

在这里插入图片描述

1. 安装

  1. 需要使用npm安装
npm i weui-miniprogram -S --production
npm install @miniprogram-component-plus/index-list
  1. 在app.wxss中加入以下代码:
/**app.wxss**/
@import './miniprogram_npm/weui-miniprogram/weui-wxss/dist/style/weui.wxss';
  1. 点击微信开发者工具栏-工具-构建npm:
    在这里插入图片描述

2.使用

  1. 页面中引入组件,例如我的:
# index.json
{
  "navigationBarTitleText": "选择城市",
  "navigationBarBackgroundColor": "#18af69",
  "usingComponents": {
    "mp-index-list": "@miniprogram-component-plus/index-list"
  }
}
  1. 页面中使用组件,例如我的:
# index.wxml
<mp-index-list class="city__list" list="{{lists}}" vibrated="{{ true }}" bindchoose="onChoose">
</mp-index-list>

  1. 页面js中添加数据,例如我的:
Page({
  data: {
    lists: [
      { alpha: "A", subItems: [{ name: "安庆市" }] },
      { alpha: "B", subItems: [{ name: "蚌埠市" }] },
      { alpha: "H", subItems: [{ name: "淮南市" }, { name: "淮北市" }] },
      { alpha: "M", subItems: [{ name: "马鞍山市" }] },
      { alpha: "T", subItems: [{ name: "铜陵市" }] },
      { alpha: "W", subItems: [{ name: "芜湖市" }] },
    ],
  },
})

参考文档地址:https://github.com/wechat-miniprogram/miniprogram-component-plus/blob/master/docs/index-list.md

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值