美文网首页
Vue 使用mobileSelect.js

Vue 使用mobileSelect.js

作者: 张思学 | 来源:发表于2019-10-08 10:08 被阅读0次
    1. 下载 mobileSelect
    npm install mobile-select -D
    
    1. vue 使用
    • 普通数组格式
    <template>
        <div>
            <div id="trigger5">vue-cli-demo</div>
        </div>
    </template>
    
    <script>
        import MobileSelect from 'mobile-select'
    
        export default {
            mounted() {
                var mobileSelect5 = new MobileSelect({
                    trigger: "#trigger5",
                    title: "vue-cli-demo",
                    wheels: [
                        {data: ["周日","周一","周二","周三","周四","周五","周六"]}
                    ],
                    callback:function(indexArr, data){
                        console.log(data);
                    }
                });
            }
        }
    </script>
    
    • 数据字段映射
    <div id="trigger6"></div>
    <script type="text/javascript">
        var mobileSelect6 = new MobileSelect({
            trigger: '#trigger6',
            title: 'keyMap',
            wheels: [
                        {data:[
                            {
                                id:'1',
                                title:'A',
                                children:[
                                    {id:'A1',title:'A-a'},
                                    {id:'A2',title:'A-b'},
                                    {id:'A3',title:'A-c'}
                                ]
                            },
                            {
                                id:'1',
                                title:'B',
                                children:[
                                    {id:'B1',title:'B-a'},
                                    {id:'B2',title:'B-b'},
                                    {id:'B3',title:'B-c'}
                                ]
                            },
                        ]}
                    ],
            keyMap: {
                id:'id',
                value: 'title',
                childs :'children'
            },
            callback:function(indexArr, data){
                console.log(data);
            }
        });
    </script>
    

    相关文章

      网友评论

          本文标题:Vue 使用mobileSelect.js

          本文链接:https://www.haomeiwen.com/subject/upfbyctx.html