public function actionInfo()
{
return \Yii::createObject([
'class' => 'yii\web\Response',
'format' => \yii\web\Response::FORMAT_JSON,
'data' => [
'msg' => 'hello world',
'code' => 100,
'aa' => 'bb',
],
]);
}
返回内容
{"msg":"hello world","code":100,"aa":"bb"}
自定义返回内容如何支持跨域呢?
看我这篇的方法3: