在Ember.js中,如何强制路由进入加载子状态?(In Ember.js, how can I force a route to be in the loading substate?)

编程入门 行业动态 更新时间:2024-10-27 08:39:43
在Ember.js中,如何强制路由进入加载子状态?(In Ember.js, how can I force a route to be in the loading substate?)

是否可以手动重新进入加载状态?

现在我有一个模板符合他们网页上提到的加载规则:

如果,Ember将在上述位置找到装载路线

[...]

已经找到了一个名称正确的加载模板,例如

酒吧/加载 富/加载 装载

转换到页面时,它使用此模板,这很棒。 但是,我想在我的网络请求忙时进入相同的加载状态。 目前,我正在重新实现页面中的模板并切换它,这会复制代码。 当我处于加载状态或不手动时,我宁愿告诉ember。

编辑:响应评论,网络请求设置和推送数据到模型(搜索按钮和“无限滚动”分页)

Is it possible to reenter the loading state manually?

Right now I have a template that matches the loading rule mentioned at their webpage:

Ember will find a loading route at the above location if

[...]

a properly-named loading template has been found, e.g.

bar/loading foo/loading loading

When transitioning to the page, it uses this template, which is great. However, I would like to enter that same loading state while my web request busy. Currently, I am reimplementing that template in the page and toggling it, which duplicates code. I would rather tell ember when I am in loading state or not manually.

Edit: In response to comment, the web requests both set and push data to the model (search button and "infinite scroll" pagination)

最满意答案

您可以在请求正在进行时使用transitionToRoute()过渡到(和退出)加载路径。

You could use transitionToRoute() to transition into (and out of) a loading route while your request is in progress.

更多推荐

本文发布于:2023-08-04 21:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1422029.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   加载   状态   js   Ember

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!