Ember 1.0 路由器,尝试在 handleURL 上捕获



我曾经做过类似的事情来捕获余烬 rc7 上的错误(404s):

App.Router.reopen({
    handleURL: function(url) {
        try {
            return this._super(url);
        } catch (error) {
            console.log('error');
        }
    }
});

渔获曾经有效,但现在不再有效了。

有一个"路由器整容",但我不明白它是如何打破的;以及现在如何抓住404。

只需在

路由器中设置404路由,如下所示:

App.Router.map(function() {
   this.route("404", {
       path: "*:"
   });
});

然后,您应该能够将自定义代码(例如您的console.log())粘贴到路由的activate()deactivate()钩子中。

最新更新