[英]Ember.js - Default content for outlet
抱歉,我的英語不足以描述更復雜的事物,但我會盡力而為。
我要瘋了。 我只想在Ember.js中為插座定義默認內容,但找不到任何解決方案。 我發現的示例使用url匹配,但就我而言,沒有特殊的URL可以識別默認模板。
讓我們來看看:
application <-- the application frame, contains an outlet
/ <-- the index, contains also an outlet
/foobar <-- some other stuff, which will be rendered in the outlet of index, if the URL is set => that works!
我的問題是如果URL =='/',則將默認模板呈現到索引的出口
有什么建議么?
我想我知道您在尋找什么。
在您的模板中,創建ID為“ index”的腳本。 加載“默認” URL時,該腳本中的所有內容均應顯示。
<script type="text/x-handlebars" id="index">
Welcome to my Ember.js site!
</script>
並確保在帶有“應用程序”的腳本ID中,您已設置插座。
<script type="text/x-handlebars" id="application">
<div>
Testing 1..2..3...
</div>
<div>
{{outlet}}
</div>
</script>
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.