加这一行就可以了
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
示例:
public function getList()
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return User::find()->where(['id' => 1])->all();
}
加这一行就可以了
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
示例:
public function getList()
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return User::find()->where(['id' => 1])->all();
}