如何在启用模块统一的情况下定义嵌套路由

How to define nested routes with module unification turned on

我是 Ember 的新手,我可能在某个地方犯了一个简单的错误,但我无法在一个启用了模块统一的简单应用程序中使用嵌套路由(3 层嵌套),在这两种情况下ember 3.2.0 和 3.3.0。

(我能够在没有模块统一的情况下在另一个应用程序中使用相同的路由。)

在我的应用程序中,我通过在 .bashrc 中设置以下环境变量来启用模块统一:

export EMBER_CLI_MODULE_UNIFICATION='true'
export MODULE_UNIFICATION='true'

这里是我的src/router.js的相关行:

Router.map(function() {
  this.route('peach', function() {
    this.route('pear', function() {
    });
  });
});

这里是src/ui/routes/peach/index/template.hbs:

peach
{{outlet}}

这里是src/ui/routes/peach/pear/index/template.hbs:

pear

导航到 http://localhost:4200/peach/pear 导致浏览器页面空白并出现以下错误:

jQuery.Deferred exception: this._config.collections[specifier.collection] is undefined _checkDefaultType@http://localhost:4200/assets/vendor.js:69136:11

TypeError: this._config.collections[specifier.collection] is undefined

为什么这些路由在启用模块统一的情况下无法工作,我怎样才能让它们工作?

您的路线文件而不是模板文件可能有问题。

但是,正如您所注意到的,模块统一仍在进行中,尚未准备好大量使用。我们都很期待它,但就目前而言,除非你想生活在最前沿(这可能会造成相当大的伤害),否则可能值得转向......