网友的解决方法:(我只想说,放屁!!!而且大家都在复制粘贴,浪费时间)

方法一:将button标签更换为input

<input class="layui-btn test" >test</input>

方法二:

<button type="button" class="layui-btn test" >test</button>

应用场景代码
<form class="layui-form"  action="" lay-filter="formSearch">
<div class="layui-form-item">
<label class="layui-form-label">多选</label>
<div class="layui-input-inline">
<input type="text" name="" placeholder="请输入" autocomplete="off" class="layui-input" id="demo">
<button lay-submit="" class="layui-btn" lay-filter="getVal1">取值</button>
</div>
</div>
</form>

js:

                layui.config({
base: '../../layuiadmin/' //layUI 根目录,在Areas需要多写一层 ../
}).extend({
tableSelect: 'ext/tableSelect/tableSelect',//tableSelect
formSelects: 'ext/formSelects/formSelects-v4'//formSelects
}).use(['form', 'layer', 'tableSelect', 'formSelects'], function () {
var $ = layui.$, form = layui.form, layer = layui.layer,
tableSelect = layui.tableSelect, formSelects = layui.formSelects; form.render(null, 'formSearch');
form.on('submit(getVal1)', function (data) {
console.log($("#demo").val()); return false;
//layer.msg($("#demo").val());
});
最关键的是:
return false;
return false;
return false;

妈蛋,早应该想到的,想到的时候心里觉得,逻辑上不需要,┭┮﹏┭┮,然后耽误了我至少一个小时,这脑回路。。。。。。。。。。。。。。。。。。
05-11 11:12