大神,windows中编译后js报错
Uncaught TypeError: Cannot read property 'csrfToken' of undefined
at Object.<anonymous> (app.3df1225….js:27701)
at __webpack_require__ (app.3df1225….js:20)
at Object.<anonymous> (app.3df1225….js:971)
at __webpack_require__ (app.3df1225….js:20)
at Object.<anonymous> (app.3df1225….js:27722)
at __webpack_require__ (app.3df1225….js:20)
at app.3df1225….js:66
at app.3df1225….js:69
目测是 resourses/assets/js/bootstrap.js
第31行 window.Laravel.csrfToken
未定义
github 上面相关作者给出的答案是在页面添加代码:
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
</script>
这目测很不科学,很不友好。大神有更好的解决方案吗?