在Ember.js中创建新路由总是会导致默认的index.html文件



我是学习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

您在router.js文件中犯了一个错误。它应该看起来像这样:

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

查看文档,/在路由名称之前是不必要的,您可能试图使用路径不同于路由名称的语法,如

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

最新更新