Giter Site home page Giter Site logo

multiselector's Introduction

微信小程序多选组件

类似与小程序picker组件的多项选择组件

效果

How to use

example.json

{
  "usingComponents": {
    "multi-selector": "/components/multiSelector/multiSelector"
  }
}

example.wxml

<multi-selector class='selector' value='{{value}}' bindchange='bindSelectorChange' bindmodalopen='onModalOpen' placeholder='请选择你喜欢的水果' items='{{items}}' bindmodalclose='onModalClose' show-value='{{false}}'></multi-selector>

example.js

Page({
  data: {
    value: ['A','B','D','F','G'],
    items: [{name: 'A',value: '苹果'},{name: 'B',value: '橘子'},{name: 'C',value: '香蕉'},{name: 'D',value: '西瓜'},{name: 'E',value: '梨子'},{name: 'F',value:'火龙果'},{name: 'G',value: '车厘子'}]
  },
  //事件处理函数

  onLoad: function () {

  },
  onModalOpen(){

  },
  onModalClose(){

  },
  bindSelectorChange(e){
	this.setData({
		value: e.detail.value
	})
  }
})

属性说明

属性名 类型 默认值 说明
value Array [] 默认选择的值
items Array [] 数组每一项包含{name: '',value: ''}
placeholder String '' 输入框为空时占位符
placeholder-class String "input-placeholder" 指定 placeholder 的样式类
placeholder-style String 指定 placeholder 的样式
disabled Boolean false 是否被禁用
show-value Boolean true 结果显示的是选择的值,还是已选中的每一项(有点绕,请看上面的图)
close-on-click-modal Boolean true 点击遮罩层是否关闭选择区
cancel-button-text String '取消' 取消键文字
confirm-button-text String '确定' 确定键文字

事件说明

事件名 说明
change 点击确定时触发,通过e.detail.value获得组件的值
modalopen 选择区打开时触发
modalclose 选择区关闭时触发

一些tips

  • 滑动的时候禁止页面跟随滑动,通过modalopenmodalclose动态修改页面的overflow

todos

  • 优化动画效果

multiselector's People

Contributors

fchengjin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

multiselector's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.