yii 返回json数据

YII 报错:

Response content must not be an array

 

yii 在 Controller 中返回数据,要加返回数据前加下面代码:

Yii::$app->response->format = Response::FORMAT_JSON;

返回的数据为 return array(),举个栗子:

return [
    'id' => $id,
    'remark' => $remark,
];

 

posted @ 2020-03-06 11:52  GetcharZp  阅读(343)  评论(0编辑  收藏  举报