
Trying to access array offset on value of type null
报错: Trying to access array offset on value of type null 框架: thinkphp5.1+layui 问题分析: (前台界面) (后端代码)
//编辑渲染 public function edit(Request $request) { $result = RcryModel::get($request->param('bh')); $this -> view -> assign('result', $result); return $this -> view -> fetch('edit'); }(前端代码)
<form class="layui-form"> <input type="hidden" id="bh" name="bh" autocomplete="off" class="layui-input" value="{$result.bh}" > </form> <script> 部分代码如下①: {field: 'id', title: 'ID', width: '5%',hide:'true',templet:function(d){return '<div style = "text-align:center">'+d.id+'</div>'},} 部分代码如下②: content: ['{:url("Rcry/edit")}?bh=' + data.bh, 'yes'], </script>错误原因: 数据库中rcry表无bh字段,而是id。故而,当点击编辑的时候,无法获取数据表格中的bh信,$result为空。将前后端传值的bh均改为id即可解决问题。
👁️ 阅读量:0
© 版权声明:本文《Trying to access array offset on value of type null》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686959868a409031.html。