因为初始化方法内return是无效的,所以使用send(),配合exit()解决
protected function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET, POST, PATCH, PUT, DELETE');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: Accept, Authorization, Origin, token, DNT, Cache-Control, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With, X-Mx-ReqToken, Keep-Alive, User-Agent,x-access-sign, x-access-time');
header('X-Powered-By: WAF/2.0');
if (request()->isOptions()) {
exit();
}
//调用
$this->checkTokens();
}
public function test()
{
ResJsonData::JsonData(1111)->send();
exit();
}
网友评论