Parses a raw HTTP request using yii\helpers\Json::decode()
To enable parsing for JSON requests you can configure yii\web\Request::$parsers using this class:
'request' => [
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
]
1、将以上配置添加到main.php 中的 components數組裡面
2、用postman模拟
header頭傳參數: Content-Type: application/json