省市區(qū)聯(lián)動(dòng)選擇,目前最完美的。 2018-12-05 優(yōu)化設(shè)置默認(rèn)值的方法,重新下載覆蓋原文件, 2018-12-13 修復(fù)可以使用多個(gè)選擇的bug
<script src="/LayuiAdmin/layui/layui_exts/city-picker/city-picker.data.js"></script>body部分:
<link href="/LayuiAdmin/layui/layui_exts/city-picker/city-picker.css" rel="stylesheet" />
<div class="layui-inline">foot部分
<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>
<script>支持界面上放置多個(gè)下拉選擇,
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>
<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", {可控制級(jí)別的
provincename:"provinceId",
cityname:"cityId",
districtname:"districtId"
});
//currentPicker.setValue("河南省/信陽(yáng)市/新縣");
var currentPicker2 = new cityPicker("#city-picker2", {
provincename: "provincenameid2",
cityname: "citynameid2",
districtname: "districtnameid2"
});
var currentPicker = new cityPicker("#city-picker", {使用有問(wèn)題,聯(lián)系QQ:340114173
provincename:"provinceId",
cityname:"cityId",
districtname: "districtId",
level: 'districtId',// 級(jí)別
});