Trying to access array offset on value of type null

编程知识 更新时间:2023-04-06 10:45:18

报错: 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即可解决问题。

更多推荐

Trying to access array offset on value of type null

本文发布于:2023-04-06 10:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/d7cf1059b9b22bdf88a9dcf71618268b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:array   access   offset   null   type

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 49126文章数
  • 14阅读数
  • 0评论数