laravel - 类型错误 : Cannot read properties of null (reading 'dataset' ) in Laravel Jetstream-inertia

标签 laravel npm webpack inertiajs jetstream

这个错误突然出现。我尝试重新安装 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/

相关文章:

php - 在laravel中下载后删除文件

javascript - Karma - 找不到模块 : Error: Cannot resolve module 'scss'

backbone.js - Webpack ProvidePlugin 与外部插件?

vue.js - vue-cli 解析 xlink :href in svgs when referenced in <img src ="">

php - Laravel Eloquent 关系无 key

Laravel 5.5 安装不生成 .env 文件

php - Laravel 加入 Auth 表

node.js - 'npm i --package-lock-only' 是做什么的?

node.js - 如何从命令行安装某些 Node 版本