问题如下
提示响应内容不能是数组
解决方法(操作前加上)
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
如下
public function actionData(){
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$data = Goods::find()->asArray()->all();
return $data;
}
到此解决