<form class="layui-form" action="" lay-filter='testForm'>
<div class="layui-form-item">
<label class="layui-form-label">账号</label>
<div class="layui-input-block">
<input type="text" name="username" 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="pass" class="layui-input">
</div>
</div>
</form>
获取表单所有值:
let data = layui.form.val(`testForm`);
console.log("?? ~ file: widget.js ~ line 209 ~ data", data);
表单赋值默认值:
layui.form.val("testForm", {
"username": "lele"
,"pass": "123456"
});