9***@qq.com
9***@qq.com
  • 发布:2016-08-28 14:05
  • 更新:2016-08-28 14:33
  • 阅读:2802

picker(选择器)为什么我不能启动

分类:MUI

代码是照贴过来的,js路径都是对的,但是无法启动

            <div class="mui-content-padded">  
                <h5 class="mui-content-padded">原生 SELECT</h5>  
                <select class="mui-btn mui-btn-block">  
                    <option value="item-1">item-1</option>  
                    <option value="item-2">item-2</option>  
                    <option value="item-3">item-3</option>  
                    <option value="item-4">item-4</option>  
                    <option value="item-5">item-5</option>  
                </select>  
                <br />  
                <p>原生 SELECT(选择框)在不同的设备上UI可能会有差异,并且不支持多级联动(多个 SELECT 可实现,但较麻烦),故mui封装了picker组件,参见如下示例。</p>  
                <h5 class="mui-content-padded">普通示例</h5>  
                <button id='showUserPicker' class="mui-btn mui-btn-block" type='button'>一级选择示例 ...</button>  
                <div id='userResult' class="ui-alert"></div>  
                <h5 class="mui-content-padded">级联示例</h5>  
                <button id='showCityPicker' class="mui-btn mui-btn-block" type='button'>二级联动示例 ...</button>  
                <div id='cityResult' class="ui-alert"></div>  
                <button id='showCityPicker3' class="mui-btn mui-btn-block" type='button'>三级联动示例 ...</button>  
                <div id='cityResult3' class="ui-alert"></div>  
            </div>  
        <link rel="stylesheet" href="<?php echo HomeUrl('themes/Mobile/css/mui.picker.css'); ?>"/>  
        <link rel="stylesheet" href="<?php echo HomeUrl('themes/Mobile/css/mui.poppicker.css'); ?>"/>  

        <script src="<?php echo HomeUrl('themes/Mobile/js/mui.picker.js'); ?>"/></script>  
        <script src="<?php echo HomeUrl('themes/Mobile/js/mui.poppicker.js'); ?>"/></script>  

        <script src="<?php echo HomeUrl('themes/Mobile/js/city.data.js'); ?>"/></script>  
        <script src="<?php echo HomeUrl('themes/Mobile/js/city.data-3.js'); ?>"/></script>  

            <script>  
            (function($, doc) {  
                $.init();  
                $.ready(function() {  
                    //普通示例  
                    var userPicker = new $.PopPicker();  
                    userPicker.setData([{  
                        value: 'ywj',  
                        text: '董事长 叶文洁'  
                    }, {  
                        value: 'aaa',  
                        text: '总经理 艾AA'  
                    }, {  
                        value: 'lj',  
                        text: '罗辑'  
                    }, {  
                        value: 'ymt',  
                        text: '云天明'  
                    }, {  
                        value: 'shq',  
                        text: '史强'  
                    }, {  
                        value: 'zhbh',  
                        text: '章北海'  
                    }, {  
                        value: 'zhy',  
                        text: '庄颜'  
                    }, {  
                        value: 'gyf',  
                        text: '关一帆'  
                    }, {  
                        value: 'zhz',  
                        text: '智子'  
                    }, {  
                        value: 'gezh',   
                        text: '歌者'  
                    }]);  
                    var showUserPickerButton = doc.getElementById('showUserPicker');  
                    var userResult = doc.getElementById('userResult');  
                    showUserPickerButton.addEventListener('tap', function(event) {  
                        userPicker.show(function(items) {  
                            userResult.innerText = JSON.stringify(items[0]);  
                            //返回 false 可以阻止选择框的关闭  
                            //return false;  
                        });  
                    }, false);  
                    //-----------------------------------------  
                    //级联示例  
                    var cityPicker = new $.PopPicker({  
                        layer: 2  
                    });  
                    cityPicker.setData(cityData);  
                    var showCityPickerButton = doc.getElementById('showCityPicker');  
                    var cityResult = doc.getElementById('cityResult');  
                    showCityPickerButton.addEventListener('tap', function(event) {  
                        cityPicker.show(function(items) {  
                            cityResult.innerText = "你选择的城市是:" + items[0].text + " " + items[1].text;  
                            //返回 false 可以阻止选择框的关闭  
                            //return false;  
                        });  
                    }, false);  
                    //-----------------------------------------  
                    //                  //级联示例  
                    var cityPicker3 = new $.PopPicker({  
                        layer: 3  
                    });  
                    cityPicker3.setData(cityData3);  
                    var showCityPickerButton = doc.getElementById('showCityPicker3');  
                    var cityResult3 = doc.getElementById('cityResult3');  
                    showCityPickerButton.addEventListener('tap', function(event) {  
                        cityPicker3.show(function(items) {  
                            cityResult3.innerText = "你选择的城市是:" + (items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text;  
                            //返回 false 可以阻止选择框的关闭  
                            //return false;  
                        });  
                    }, false);  
                });  
            })(mui, document);
2016-08-28 14:05 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com (作者)

犯了个低级错误,js最后没写</script>

该问题目前已经被锁定, 无法添加新回复