【发布时间】:2025-12-28 12:30:11
【问题描述】:
我正在开发一个 Ember 2.6 应用程序,但在刷新页面时遇到了问题。这看起来是一个常见问题,所以我找到并更新了我的.htaccess 文件,如下所示:
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
因此,每当我刷新以下 URL 时,这都会起作用:http://danyuschick.com/projects
但是,每当我刷新时它都不会加载:http://danyuschick.com/projects/14
这是我的路由器:
Router.map(function() {
this.route('about');
this.route('blogs');
this.route('projects', function() {
this.route('index', { path: '/' });
this.route('project', { path: '/:project_id' });
});
this.route('error', { path: '*path' });
this.route('loading');
});
还有我定义模型的路线
model(params) {
return this.store.findRecord('projects', params.project_id);
}
我不确定这个更新需要在哪里进行,htaccess 或我的路由器或什么。
【问题讨论】:
-
试试 this.store.findRecord('project', params.project_id); - ember-data 默认情况下它会复数模型和数据请求
-
不走运,@kumkanillam。刷新时没有加载任何文件或样式的结果仍然相同。虽然我可以看到没有控制台错误,
-
虽然我可以说刷新后 params.project_id 仍然正确填充。
-
刷新时 projects/index.hbs 将被 projects/14 覆盖 ..所以你需要将 projects/index.hbs 移动到 projects.hbs ..如果你不明白,我会提供样品旋转...
-
谢谢,@kumkanillam。我想我需要一个例子。现在 app/projects.hbs 只是我的 {{liquid-outlet}} 而我的 projects/index.hbs 是 {{component 'list' model=model}}。所以我不确定这将如何重新设计。
标签: javascript .htaccess ember.js firebase ember-cli