search

Home  >  Q&A  >  body text

javascript - How to assign the data queried in thinkphp5 controller to js?

How to assign the data queried in thinkphp5 controller to js?

public function index(){
        $data = Db::name('menu') -> select();
        $data = node_merge($data);
        //这个$data如何传给前端js?
        return $this -> fetch();
    }
大家讲道理大家讲道理2750 days ago691

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-26 10:54:21

    Method added

    $this->assign('data',$data);

    View js

    var data="{{$data}}";

    reply
    0
  • Cancelreply