picker 仿Iphone的时间选择器

可查看链接 https://zhuanlan.zhihu.com/p/22006728

引入 picker.min.js

基于require.js的应用

当时为了项目需要 只是实现单一的选项;  联动等业务忘却了;

定义//仿iphone 列表
    function Popup(picker, data) {
        var first = [];
        /* 省,直辖市 */
        var selectedIndex = [0];
        /* 默认选中的地区 */
        function creatList(obj, list) {
            obj.forEach(function (item, index) {
                var temp = new Object();
                temp.text = item.text;
                temp.value = index;
                list.push(temp);
            })
        }
        creatList(data, first);
        ////console.log(first)
        var picker = new picker({
            data: [first],
            selectedIndex: selectedIndex,
        });
        picker.show();
        picker.on('picker.select', function (selectedVal, selectedIndex) {
            $(".dianjile").prev().html(first[selectedIndex[0]].text);
            $(".dianjile").removeClass("dianjile")
        });
    }运用
$(".ullist li").eq(0).on("click", function () {
                    $(this).find("span").eq(3).addClass("dianjile");
               popup(picker,data);
            })

猜你喜欢

转载自blog.csdn.net/qinlulucsdn/article/details/80163305