找到/vendor/yiisoft/yii2/web/Controller.php
在200行左右
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
if ($this->enableCsrfValidation && Yii::$app->getErrorHandler()->exception === null && !$this->request->validateCsrfToken()) {
throw new BadRequestHttpException(Yii::t('yii', 'Unable to verify your data submission.'));
}
return true;
}
return false;
}
将!$this->request->validateCsrfToken()替换成!Yii::$app->getRequest()->validateCsrfToken()
改成这样可以,不懂php,有问题还请纠正