ember.js route转换,但模板不呈现?(ember.js route Transitioned, but Template not render?)

编程入门 行业动态 更新时间:2024-10-28 02:21:52
ember.js route转换,但模板不呈现?(ember.js route Transitioned, but Template not render?)

关于这个代表演示 。

路线:

this.resource('index',{path:'/'}, function(){ this.route('login',{path:'/login'}); this.route('signup',{path: '/signup'}); })

指数

- 登录

- 注册


index - render index.hbs - > index_login.hbs

index.login --render index.hbs - > index_login.hbs

index.signup --render index.hbs - > index_signup.hbs


我不知道! 我只想重用index.hbs ,但我不知道如何控制。

about this reps demo.

route:

this.resource('index',{path:'/'}, function(){ this.route('login',{path:'/login'}); this.route('signup',{path: '/signup'}); })

index

- login

- signup


index -- render index.hbs -> index_login.hbs

index.login --render index.hbs -> index_login.hbs

index.signup --render index.hbs -> index_signup.hbs


I have no idea! I just want to reuse index.hbs, but I don't how to control.

最满意答案

根据您的代码:

<div class="well"> <h1>index</h1> {{outlet}} Welcome Ember.js! {{#link-to 'index.signup'}}signup{{/link-to}} </div>

默认情况下(不覆盖route.renderTemplate),当您在每个特定路由上输入时, {{outlet}}将在index / login.hbs或index / signup.hbs的内容时自动更新。

<script type="text/x-handlebars" data-template-name="index/login"> <script type="text/x-handlebars" data-template-name="index/singup">

要在转换为“index”(IndexRoute)时显示“登录”,可以定义IndexRoute或IndexIndexRoute以重定向到IndexLoginRoute。

Yodemo.IndexIndexRoute = Ember.Route.extend({ beforeModel: function(transition) { this.transitionTo('index.login'); } });

http://emberjs.jsbin.com/titabaxe/3/edit

Based on your code:

<div class="well"> <h1>index</h1> {{outlet}} Welcome Ember.js! {{#link-to 'index.signup'}}signup{{/link-to}} </div>

By default (not overriding route.renderTemplate), the {{outlet}} will be automatically updated when the content of index/login.hbs or index/signup.hbs when you enter on each specific route.

<script type="text/x-handlebars" data-template-name="index/login"> <script type="text/x-handlebars" data-template-name="index/singup">

To show Login when you transition to 'index' (IndexRoute), you could define your IndexRoute or IndexIndexRoute to redirect to IndexLoginRoute.

Yodemo.IndexIndexRoute = Ember.Route.extend({ beforeModel: function(transition) { this.transitionTo('index.login'); } });

http://emberjs.jsbin.com/titabaxe/3/edit

更多推荐

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

发布评论

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

>www.elefans.com

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