自定义“页面不存在”页面

Hi community!

I am trying to customize the “Page doesn’t exist” page. It currently shows the words " Oops! That page doesn’t exist or is private.". However, I would like to replace this with an image instead. Is there any way to do this? I was thinking of using plugin-outlets but there does not seem to be one for it. Thanks in advance.

也许我们应该为此设立一个插件商店,@eviltrout

不幸的是,这并不简单,因为该页面有两个版本。一个是在服务器端生成的,另一个是在客户端生成的,具体取决于错误类型。我们可以在客户端页面上添加一个出口,但你并不总是能看到它。此外,我还应该指出,该页面用于所有异常,因此你需要区分网络错误、500 错误、404 错误等。

只是想确认一下,目前是否有办法解决这个问题?如果可能的话,我们也希望能修改该页面。

它没有变化,抱歉。

明白了,谢谢您的快速回复。

我能够使用一点 Javascript 来自定义消息:

window.addEventListener("DOMContentLoaded", function(){
    document.querySelector('.page-not-found .title').innerHTML = "新的消息在这里";
});

该脚本替换了“糟糕!该页面不存在或已设为私有”所在位置的 HTML。我还没有尝试过,但理论上,您可以添加 HTML 来渲染图片。