【问题标题】:Ember js routing not working in 2.10Ember js 路由在 2.10 中不起作用
【发布时间】:2017-01-07 10:49:40
【问题描述】:

我使用此 Ember 路由文件将此 URI www.example.com/home/page 与位于主文件夹中的模板 main-page.hbs 映射

export default {
    resource: 'home',
    path: '/home',
    map() {
        this.route('main-page', { path: 'page' });

    }
};

在我将应用程序从 1.2.0 升级到 2.1.0 之前,我的工作也很好。关于文档中的路由,我没有发现两个版本有任何区别。路由文档有什么变化吗?难道我做错了什么?我是 Ember js 的新手,很难理解路由文档

插件的完整源代码可用@github 我正在使用discourse 应用程序

【问题讨论】:

  • 您显示的文件是 Discourse 特定的东西。这不是在普通的 Ember 应用程序中完成路由的方式,这可能是 Ember 文档对您没有帮助的原因。

标签: javascript ember.js routes url-routing discourse


【解决方案1】:

这是router.js的当前语法示例

我不确定您的具体情况,但希望这会有所帮助。

import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  location: config.locationType,
  rootURL: config.rootURL
});

Router.map(function() {
  // note the implicit 'application' route with {{outlet}}
  this.route('main-page', { path: '/home' ); // or '/' to make it the root
  this.route('rainbow', function() {
    this.route('red');
    this.route('orange');
    // ... nested
  this.route('vampire');
});

export default Router;

https://guides.emberjs.com/v2.1.0/routing/defining-your-routes/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 2017-11-04
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    • 2021-07-18
    相关资源
    最近更新 更多