HTML表单:
<div class="layui-form-item">
<label class="layui-form-label">消息通知</label>
<div class="layui-input-block">
<input name="is_notice" value="1" type="radio" title="通知" checked="">
<input name="is_notice" value="0" type="radio" title="不通知">
</div>
</div>
JS用ajax去后端取回数据:
$.get(
"{:url('user/xxxx')}",
{'id':adminId},
function(d){
//设置是否通知
if(d.is_notice == 0){
$("input[name=is_notice][value=1]").prop("checked","false");
$("input[name=is_notice][value=0]").prop("checked","true");
}
form.render(); //更新全部
}
);
切记最后的form.render(); 不能漏
(layui使用之前引入操作省略)
mark it.