gpt4 book ai didi

ember.js - Query-params-new 嵌套路由奇怪的错误

转载 作者:行者123 更新时间:2023-12-02 18:59:29 33 4
gpt4 key购买 nike

在应用程序中,我对 Ember 和 Ember 数据使用最新的金丝雀版本。我有以下路由器:

this.resource('articles', {path: '/articles'}, function() { 
this.resource('article', {path: '/:article_id'});
});

ArticlesController中,我指定了一些查询参数:

queryParams: ['category', 'search'],
category: '1', // defaults to 1
searchTerm: "",

在我的ArticlesRoute中,我指定模型刷新和模型:

queryParams: {
category: {
refreshModel: true
}
},

model: function(params) {
// here I do use the params to return articles based on category and/or searchTerm
}

到目前为止一切顺利,上面的所有代码都运行完美。但是,当我在应用程序中执行 this.transitionTo('article',articleObject)this.transitionToRoute('article',articleObject) 时,出现以下错误:

Error: You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route article
at Object.__exports__.default.subclass.createParamHandlerInfo (http://localhost:8000/vendor/ember/index.js:44242:21)
at Object.__exports__.default.subclass.applyToHandlers (http://localhost:8000/vendor/ember/index.js:44121:37)
at Object.__exports__.default.subclass.applyToState (http://localhost:8000/vendor/ember/index.js:44088:21)
at Object.Router.transitionByIntent (http://localhost:8000/vendor/ember/index.js:43312:33)
at Object.Router.refresh (http://localhost:8000/vendor/ember/index.js:43459:21)
at EmberObject.extend.refresh (http://localhost:8000/vendor/ember/index.js:22616:35)
at EmberObject.extend._actions.queryParamsDidChange (http://localhost:8000/vendor/ember/index.js:22328:22)
at Object.triggerEvent (http://localhost:8000/vendor/ember/index.js:24563:38)
at trigger (http://localhost:8000/vendor/ember/index.js:44812:16)
at fireQueryParamDidChange (http://localhost:8000/vendor/ember/index.js:43612:9) index.js:14220
Uncaught Error: Assertion Failed: Error: You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route article index.js:3658

这个奇怪的错误仅在我第一次单击类别时发生,因此 queryParam category 发生更改,然后触发过渡到 文章

我尝试使用debugger;语句来获取错误的来源。然而,似乎这是一个调用此错误的事件。在搜索源代码时,我发现错误源自 ember.js 的第 44242 行。

有谁知道为什么在我转换到 query-params-new 路由后会发生此错误?

编辑:现在也在 Github 中:https://github.com/emberjs/ember.js/issues/5070(Github 上的评论)JSBin:http://emberjs.jsbin.com/yiquyupa

最佳答案

我在 afterModel 回调中遇到了几乎相同的问题,其中父路由/ Controller 具有 queryParams。

我发现,如果您只是将 queryParams 从 transition 参数(而不是 null/未定义的 queryParams 参数)传递到 Route.transitionTo/Route .replaceWith 然后转换完成。

示例:

 afterModel: function(model, transition, queryParams) {
// FIXME: unresolved Ember issue https://github.com/emberjs/ember.js/issues/5070
this.replaceWith('another.route', model, { queryParams: transition.queryParams});
}

我不知道为什么会发生这种情况,但 queryParams 仍然是一个相对较新的功能,并且仍然有一些粗糙的边缘。

关于ember.js - Query-params-new 嵌套路由奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24412443/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com