vue 项目一加载create 就申请新的token 然后传输过去
var params = new URLSearchParams();
axios.post(this.url + 'vdata/vdata_cate/getToken', params).then((response) => {
this.token = response.data;
});
php生成token
public function getToken() {
header('Access-Control-Allow-Origin:*');//允许所有来源访问
header('Access-Control-Allow-Method:POST,GET');//允许访问的方式
$request = \think\facade\Request::instance();
return $request->token();
}
//错误信息
protected $message =[
//表单令牌第7步
'__token__.require' => '非法提交',
'__token__.token' => '请不要重复提交表单',
被请不要重复提交表单所拦截