新入门,输入框可以显示,下拉选择框和复选框,开光不能显示

提问 已结 19 364
颂乐
颂乐 2019-11-21
悬赏:20飞吻
版本:layui 浏览器:谷歌
写入了js代码,src路径没问题,就是下拉选择框和复选框开关显示不出来,单选框选不出来
回帖
  • @颂乐 你下载下来的layui包,你别去改动它内容模块文件的位置,因为很多模块都是相互依赖的,你现在这种方式,已经破坏了模块之间的关系了。
    下载的layui包,之间把它的整个不动的仍进你的项目里面就好
    0 回复
  • 这些都需要form.js
    <script>
    layui.use(['form'], function(){
    var form = layui.form;
    });
    </script>
    0 回复
  • 颂乐
    2019-11-21
    @MrRainbow 我引入了form.js 而且写了加载代码,还是不行。。。。
    0 回复
  • 颂乐
    2019-11-21
    @MrRainbow 我引入了form.js 而且写了加载代码,还是不行。。。。
    0 回复
  • @颂乐 那就得看你前端代码哪里没写到了。
    这是官网的标注案例,你可以将代码放在这里直接运行测试:https://www.layui.com/demo/
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css" media="all">
    <!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
    </head>
    <body>

    <blockquote class="layui-elem-quote layui-text">
    鉴于小伙伴的普遍反馈,先温馨提醒两个常见“问题”:1. <a href="/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示?</a> 2. <a href="/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新?</a>
    </blockquote>


    <!-- 示例-970 -->
    <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>赋值和取值</legend>
    </fieldset>

    <form class="layui-form" action="" lay-filter="example">
    <div class="layui-form-item">
    <label class="layui-form-label">输入框</label>
    <div class="layui-input-block">
    <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">密码框</label>
    <div class="layui-input-block">
    <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">选择框</label>
    <div class="layui-input-block">
    <select name="interest" lay-filter="aihao">
    <option value=""></option>
    <option value="0">写作</option>
    <option value="1">阅读</option>
    <option value="2">游戏</option>
    <option value="3">音乐</option>
    <option value="4">旅行</option>
    </select>
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">复选框</label>
    <div class="layui-input-block">
    <input type="checkbox" name="like[write]" title="写作">
    <input type="checkbox" name="like[read]" title="阅读">
    <input type="checkbox" name="like[daze]" title="发呆">
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">开关</label>
    <div class="layui-input-block">
    <input type="checkbox" name="close" lay-skin="switch" lay-text="ON|OFF">
    </div>
    </div>

    <div class="layui-form-item">
    <label class="layui-form-label">单选框</label>
    <div class="layui-input-block">
    <input type="radio" name="sex" value="男" title="男" checked="">
    <input type="radio" name="sex" value="女" title="女">
    </div>
    </div>
    <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">文本域</label>
    <div class="layui-input-block">
    <textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
    </div>
    </div>

    <div class="layui-form-item">
    <div class="layui-input-block">
    <button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-setval">赋值</button>
    <button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-getval">取值</button>
    <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
    </div>
    </div>
    </form>


    <script src="//res.layui.com/layui/dist/layui.js" charset="utf-8"></script>
    <!-- 注意:如果你直接复制所有代码到本地,上述js路径需要改成你本地的 -->
    <script>
    layui.use(['form'], function(){
    var form = layui.form;
    });
    </script>

    </body>
    </html>
    0 回复
  • 颂乐
    2019-11-21
    @MrRainbow 我把官方代码贴进去了,css,js路径都改了,还是不行。。。。
    0 回复
  • 把你前端代码贴出来,浏览器中查看你的JS、CSS是否都已引进。[生病]
    0 回复
  • 颂乐
    2019-11-21
    @MrRainbow
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">

    <title>入门尝试</title>
    <link rel="stylesheet" href="css/layui.css" media="all">
    <script src="js/layui.js" charset="utf-8"></script>
    <script src="js/form.js" charset="utf-8"></script>
    </head>
    <body>
    <form class="layui-form" action="">
    <div class="layui-form-item">
    <label class="layui-form-label">输入框</label>
    <div class="layui-input-block">
    <input type="text" name="title" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">密码框</label>
    <div class="layui-input-inline">
    <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">辅助文字</div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">选择框</label>
    <div class="layui-input-block">
    <select name="city" lay-verify="required">
    <option value=""></option>
    <option value="0">北京</option>
    <option value="1">上海</option>
    <option value="2">广州</option>
    <option value="3">深圳</option>
    <option value="4">杭州</option>
    </select>
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">复选框</label>
    <div class="layui-input-block">
    <input type="checkbox" name="like[write]" title="写作">
    <input type="checkbox" name="like[read]" title="阅读" checked>
    <input type="checkbox" name="like[dai]" title="发呆">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">开关</label>
    <div class="layui-input-block">
    <input type="checkbox" name="switch" lay-skin="switch">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">单选框</label>
    <div class="layui-input-block">
    <input type="radio" name="sex" value="男" title="男">
    <input type="radio" name="sex" value="女" title="女" checked>
    </div>
    </div>
    <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">文本域</label>
    <div class="layui-input-block">
    <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
    </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>
    layui.use(['form'], function(){
    var form = layui.form;
    });
    </script>
    </body>
    </html>
    0 回复
  • @颂乐 ]
    0 回复
  • 0 回复