这个错误突然出现。我尝试重新安装 npm 软件包,但它不起作用。但是当我使用相同的 npm 包创建一个新的 jetstream-inertia 项目时,它就会起作用。 有帮助吗? 在 Chrome 上测试:
app.js:10 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dataset')
at exports.createInertiaApp (app.js:10)
at Module../resources/js/app.js (app.js:27154)
at __webpack_require__ (app.js:53738)
at app.js:53903
at Function.__webpack_require__.O (app.js:53775)
at app.js:53905
最佳答案
您需要将 defer
属性添加到 head 标记内的 script 标记中,如下所示:
<head>
........
<script src="{{ mix('/js/app.js') }}" defer></script>
</head>
或者,您可以将脚本添加到脚本部分的 @inertia
标记下方,不包括 defer
属性,如下所示:
@inertia
<script src="{{ mix('/js/app.js') }}"></script>
.......
</body>
关于laravel - 类型错误 : Cannot read properties of null (reading 'dataset' ) in Laravel Jetstream-inertia,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70028685/