【问题标题】:Ember.js Creating a new route in ember.js always lead to default index.html fileEmber.js 在 ember.js 中创建新路由总是会导致默认 index.html 文件
【发布时间】:2021-11-02 10:42:02
【问题描述】:

我是学习 ember.js 的新手,我已经学习了一些教程,但我不知道为什么它对我不起作用。 我想要的是用游戏创建一条新路线:http://localhost:4200/jeux 所以我做到了:

ember g route jeux

创建一个新路由“/jeux” 我已经用 jeux.hbs 完成了这个新页面:

{{page-title "Jeux"}}
<p>La page des jeux-vidéos</p>

现在我不知道为什么 http://localhost:4200/jeux 仍然指向默认的 index.html 页面 [http://localhost:4200 的图像][1] [http://localhost:4200/jeux 的图片][2] 谢谢您的帮助! 这里有一些图片可以帮助理解我的项目 (这是我用“ember new the project name”生成的一个简单项目)

[image of file "router.js"][3]
[basic default "index.html"][4]
[the evironment.js file][5]
[1]: https://i.stack.imgur.com/JAzuf.png
[2]: https://i.stack.imgur.com/LBrFB.png
[3]: https://i.stack.imgur.com/gQunM.png
[4]: https://i.stack.imgur.com/FEa93.png
[5]: https://i.stack.imgur.com/UaXfp.png

【问题讨论】:

  • 欢迎来到 Stack Overflow!请不要将您的代码作为图像附加,而是使用代码块。
  • 欢迎您!请始终记住在发布之前检查您的帖子的预览。在这种情况下,您的所有链接都没有正确格式化。祝你好运:D

标签: javascript url ember.js routes


【解决方案1】:

您在router.js 文件中犯了一个错误。 它应该是这样的:

Router.map(function() {
  this.route('jeux');
});

在不需要路由名称之前查看documentation/,您可能尝试使用与路径名称不同的语法,例如

Router.map(function() {
  this.route('jeux', {path:'/jeux'});
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-03
    • 1970-01-01
    • 2013-01-16
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 1970-01-01
    • 2014-10-03
    相关资源
    最近更新 更多