如何修复php artisan make:auth之后的ckeditor错误



我正在使用ckeditor进行Laravel项目。编辑器运行得很好,控制台中没有错误,直到我运行:

php artisan make:auth

项目登录/注册随后工作,但编辑器没有在控制台中显示错误:

Uncaught TypeError: a.ui.space(...) is null

我追踪到在auth-build:期间添加到app.flade.php文件中的行

<script src="{{ asset('js/app.js') }}" defer></script>

如果我删除defer,编辑器会返回,但我现在得到控制台错误:

[Vue warn]: Cannot find element: #app

我看到了很多关于编辑错误的帖子,但它们并没有帮助我找到问题的根源。你知道如何正确纠正错误吗?

我认为问题在于脚本是在DOM元素加载到DOM之前执行的。或者您已经将它放在目标元素之前,然后当脚本调用时,它找不到该元素。

因此,您可以将脚本放置在加载事件处理程序中,类似于以下内容:

window.onload = function () {
// your script here
}

window.addEventListener('load', function () {
// your script here
}

最新更新