[英]What is the difference between route and path in EmberJs
EmberJs中路由和路徑有什么區別
Router.map(function () {
this.route('about');
this.route('contact', { path: '/getting-in-touch' });
});
route 的第一個參數是route
的名稱。 它用於找到正確的文件來加載app/routes/about.js
並提供鏈接<LinkTo @route="about">About</LinkTo>
。 如果您提供path
選項,它將用於創建您在瀏覽器的地址欄中看到的 URL。
來自余燼指南
如果路徑與路由名稱相同,則可以省略該路徑。
對於您的情況,以下是等效的:
Router.map(function () {
this.route('about', { path: '/about' });
this.route('contact', { path: '/getting-in-touch' });
});
Router.map(function () {
this.route('about');
this.route('contact', { path: '/getting-in-touch' });
});
將導致 Ember 知道如何加載https://yoursite.com/about
和https://yoursite.com/getting-in-touch
的 URL
對於<LinkTo @route="contact">Contact Us</LinkTo>
創建與 HTML 的鏈接,例如<a href="https://yoursite.com/getting-in-touch">Contact Us</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.