SOURCE

console 命令行工具 X clear

                    
>
console
<form class="layui-form" action=""><br>
  <div class="layui-form-item">
    <label class="layui-form-label">选择框1</label>
    <div class="layui-input-block">
      <select name="city" lay-verify="required" lay-filter="area">
        <option value=""></option>
        <option value="0">北京</option>
        <option value="1">上海</option>
        <option value="2">广州</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">选择框2</label>
    <div class="layui-input-block">
      <select name="county" lay-verify="required" lay-filter="county">
        <option value=""></option>
        <option value="0">北京</option>
        <option value="1">上海</option>
        <option value="2">广州</option>
      </select>
    </div>
  </div>
</form>
 
<script>
//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('select(area)', function(data){
    layer.msg(`我是选中的值:${JSON.stringify(data.value)}`);
    // 此处模拟Ajax请求
    setTimeout(() => {
        $('select[name=county]').val(data.value)
        form.render()
        layer.msg(`已加载"${data.value}"!`);
    }, 100)
  });
});
</script>

本项目引用的自定义外部资源