npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

m-picker

v1.1.1

Published

m-picker 模拟ios原生select的选择器

Downloads

8

Readme

m-picker


模拟ios原生select的选择器
用户需要选择操作时,在手机下方弹出选择器

何时使用

分为 -单值选择器 -多值选择器: -需要从一组相关联的数据集合进行选择,例如省市区,公司层级,事物分类等。 -从一个较大的数据集合中进行选择时,用多级分类进行分隔,方便选择。

<Picker {...opt1} placeholder="picker 选择1" />

API

选择器容器<Picker>的属性说明如下:

| 参数 | 说明 | 类型 | 默认值 | |----------|----------------|----------|--------------| | onOpen |打开选择器回调 |Function | noop | | onChange | 选择器的值改变的回调 | Function | noop | | onClose | 关闭选择器回调 | Function | noop | | toolbar | 是否显示toolbar | boolean | false | | toolbarTitle | toolbar的标题 | String或DOM | '' | | showSubmitBtn | 是否显示确认按钮| boolean | true | | showClearBtn | 是否显示清除按钮 | boolean | false | | formatValue | 格式化cols中values和displayValues的方法 | Function | noop | | cols | 配置选择器的部分属性 | Array<object> | {} | | cols[i].classNames | 选项列表的className | string | '' | | cols[i].textAlign | 选项列表的对齐方式,可选值有'left', 'right', 'center' | string | 'center' | | cols[i].values | 选项列表的值 | Array<string> | [] | | cols[i].displayValue | 选项列表的显示值(如果有的话) | Array<string> | undefined |

import { Input,Picker,FormItem } from '@ali/msui-react';
const opt1 = {
    cols: [{
        values: ['iPhone 4', 'iPhone 4S', 'iPhone 5', 'iPhone 5S', 'iPhone 6', 'iPhone 6 Plus', 'iPad 2', 'iPad Retina', 'iPad Air', 'iPad mini', 'iPad mini 2', 'iPad mini 3']
    }]
}
ReactDOM.render(
    <div>
        <h4>单个值的picker</h4>
        <FormItem>
            <Picker {...opt1} placeholder="picker选择1" />
        </FormItem>
    </div>
, document.getElementById('container'));

通过设置toolbartoolbarTitle来修改toolbar的显隐和文案。

通过设置showClearBtnshowSubmitBtn来控制确认和取消按钮的显隐。


import { Input,Picker,FormItem } from '@ali/msui-react';
const opt2 = {
    toolbar: true,
    toolbarTitle: '请选择设备',
    cols: [{
        textAlign: 'center',
        values: ['iPhone 4', 'iPhone 4S', ...., 'iPad mini 3'],
        displayValues: ['苹果4', '苹果4S', ...., '艾派mini3'],
        className: 'picker-items-col-normal'
    }],
    defaultValue: ['iPhone 5S']
}
ReactDOM.render(
    <div>
        <h3>显示toolbar的picker</h3>
        <FormItem>
            <Picker {...opt2} placeholder="picker 选择1" />
        </FormItem>
    </div>
, document.getElementById('container'));

多列选项的picker


import { Input,Picker,FormItem } from '@ali/msui-react';
const opt3 = {
    toolbar: true,
    toolbarTitle: '请选择姓名',
    showClearBtn: true,
    cols: [{
        values: ['赵', '钱', '孙', '李', '周', '吴', '郑', '王']
    },
    {
        values: ['杰伦', '磊', '明', '小鹏', '燕姿', '菲菲', 'Baby']
    },
    {
        values: ['先生', '小姐']
    }],
    defaultValue: ['孙', '燕姿', '小姐'],
    onClose: function() {
        console.log('closed')
    },
    onChange: function (picker, values, displayValues) {
        console.log(values, displayValues)
    }
}
  
ReactDOM.render(
    <div>
        <h3>多个值的picker</h3>
        <FormItem>
            <Picker {...opt3} placeholder="picker 选择2" />
        </FormItem>
    </div>
, document.getElementById('container'));