layui 第三方組件平臺(tái)

返回首頁(yè) 發(fā)布組件

省市區(qū)聯(lián)動(dòng)選擇,目前最完美的。 2018-12-05 優(yōu)化設(shè)置默認(rèn)值的方法,重新下載覆蓋原文件, 2018-12-13 修復(fù)可以使用多個(gè)選擇的bug

更新:2019-1-23 創(chuàng)建:2018-11-19

文檔



按插件規(guī)范添加到項(xiàng)目中,使用方式:

head部分引用:
    <script src="/LayuiAdmin/layui/layui_exts/city-picker/city-picker.data.js"></script>
<link href="/LayuiAdmin/layui/layui_exts/city-picker/city-picker.css" rel="stylesheet" />
body部分:
<div class="layui-inline">
<label class="layui-form-label width_auto text-r" style="margin-top:2px">省市縣:</label>
<div class="layui-input-inline" style="width:400px">
<input type="text" autocomplete="on" class="layui-input" id="city-picker" name="city-picker" readonly="readonly" data-toggle="city-picker" placeholder="請(qǐng)選擇">
</div>
</div>
foot部分
<script>
layui.config({
base: '/layuiadmin/' //靜態(tài)資源所在路徑
}).extend({
index: 'lib/index' //主入口模塊
, citypicker: '{/}/layuiadmin/layui/layui_exts/city-picker/city-picker' // {/}的意思即代表采用自有路徑,即不跟隨 base 路徑
}).use(['jquery', 'index', 'table', 'citypicker'], function () {
var $ = layui.$
, table = layui.table
, form = layui.form
, cityPicker = layui.citypicker;

var currentPicker = new cityPicker("#city-picker", {
provincename:"provinceId",
cityname:"cityId",
districtname: "districtId",
level: 'districtId',// 級(jí)別
});
currentPicker.setValue("河南省/信陽(yáng)市/新縣");
});

</script>
支持界面上放置多個(gè)下拉選擇,


參考用例如下:
                        <div class="layui-inline">
<label class="layui-form-label width_auto text-r" style="margin-top:2px">省市縣:</label>
<div class="layui-input-inline" style="width:400px">
<input type="text" autocomplete="on" class="layui-input" id="city-picker" name="city-picker" readonly="readonly" data-toggle="city-picker">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label width_auto text-r" style="margin-top:2px">省市縣2:</label>
<div class="layui-input-inline" style="width:400px">
<input type="text" autocomplete="on" class="layui-input" id="city-picker2" name="city-picker2" readonly="readonly" data-toggle="city-picker">
</div>
</div>
            var currentPicker = new cityPicker("#city-picker", {
provincename:"provinceId",
cityname:"cityId",
districtname:"districtId"
});
//currentPicker.setValue("河南省/信陽(yáng)市/新縣");

var currentPicker2 = new cityPicker("#city-picker2", {
provincename: "provincenameid2",
cityname: "citynameid2",
districtname: "districtnameid2"
});
可控制級(jí)別的
var currentPicker = new cityPicker("#city-picker", {
provincename:"provinceId",
cityname:"cityId",
districtname: "districtId",
level: 'districtId',// 級(jí)別
});
使用有問(wèn)題,聯(lián)系QQ:340114173

下載

立即下載 去碼云下載
該擴(kuò)展組件由第三方用戶主動(dòng)投遞,并由其自身進(jìn)行維護(hù),本站僅做收集。