思路分析:当我使用layui默认的下拉搜索框的时候,layui会默认渲染出一个HTML结构,所以我把渲染出来的这个结果直接给复制出来,这样css的样式就不用从头到尾写一遍了,
前端代码(我用的是jsp):
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="statics/css/font.css" rel="external nofollow" > <link rel="stylesheet" href="statics/css/xadmin.css" rel="external nofollow" > </head> <body> <form class="layui-form" action=""> <div class="layui-inline"> <label class="layui-form-label">搜索选择框</label> <div class="layui-input-inline"> <div class="layui-form-select layui-form-selected searchDiv"> <div class="layui-select-title"><input type="text" placeholder="直接选择或搜索选择" value="" class="layui-input search_input" id="search_input"></div> <dl class="layui-anim layui-anim-upbit" style="display: block;"> <!-- <dd lay-value="" class="layui-select-tips layui-this">直接选择或搜索选择</dd> --> <!-- <dd lay-value="1" class="layui-this">layer</dd> <dd lay-value="2" class="">form</dd> <dd lay-value="3" class="">layim</dd> --> <!-- <dd lay-value="4" class="">element</dd> <dd lay-value="5" class="">laytpl</dd> <dd lay-value="6" class="">upload</dd> <dd lay-value="7" class="">laydate</dd> <dd lay-value="8" class="">laypage</dd> <dd lay-value="9" class="">flow</dd> <dd lay-value="10" class="">util</dd> <dd lay-value="11" class="">code</dd> <dd lay-value="12" class="">tree</dd> <dd lay-value="13" class="">layedit</dd> <dd lay-value="14" class="">nav</dd> <dd lay-value="15" class="">tab</dd> <dd lay-value="16" class="">table</dd> <dd lay-value="17" class="">select</dd> <dd lay-value="18" class="">checkbox</dd> <dd lay-value="19" class="">switch</dd> <dd lay-value="20" class="">radio</dd> --> </dl> </div> </div> </div> <div class="layui-form-item"> <div class="layui-input-block"> <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button> </div> </div> </form> <script src="/UploadFiles/2021-04-02/layui.js">后台代码我就不贴了,我是认为后台没有必要贴了
以上这篇关于layui的下拉搜索框异步加载数据的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。