vue提交时出现错误: ‘_token’: LA.token, Uncaught (in promise) ReferenceError: LA is not defined
submitBtn() {
var that = this
that.$confirm('确认提交? 提交之后不能修改 !', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
that.loading = true;
jQuery.ajax({
url: "/hismaterial/saveRedo",
type: "post",
data: {
// '_token': LA.token, //这样会报错
'_token':'{{ csrf_token() }}', //改成这样子就不会了
'notice_id': that.notice_id,
'redoList': that.redoList,
'liable': that.liable,
},
dataType: 'json',
success: function (res) {
that.loading = false;
that.causeDrawer = false;
if (res.code == 1) {
that.$message({
message: res.msg,
type: 'success'
})
that.getData();
} else {
that.$message({
message: res.msg,
type: 'warning'
})
}
}
});
})
}
文件:helpers.php
if (! function_exists('csrf_token')) {
/**
* Get the CSRF token value.
*
* @return string
*
* @throws \RuntimeException
*/
function csrf_token()
{
$session = app('session');
if (isset($session)) {
return $session->token();
}
throw new RuntimeException('Application session store not set.');
}
}