【问题标题】:LinkTo not working after ember updateember 更新后 LinkTo 无法正常工作
【发布时间】:2013-10-04 17:44:48
【问题描述】:

在更新应用程序包(从 rc6 到 1.0.0 的 Ember、从 rc4 到 1.0.0 的把手和从 1.9.1 到 2.0.3 的 jquery)后,我所有的 linkTo 助手都停止工作了; 如果我点击一个链接,我会收到这个警告:

This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid. 

其他一切似乎都还好;有人可以解释一下吗?

这是我的路由器:

this.resource('eng', function(){
    this.route('home');
    this.route('aboutUs', {path: 'about-us'});
    this.route('newsArchive', {path: 'news-archive'});
    this.route('mattressesAreas', {path: 'mattresses-areas'});
    this.resource('eng.rent', {path: 'rent' }, function(){
        this.route('boulderSmall', {path: 'boulder-small'});
        this.route('boulderXl', {path: 'boulder-xl'});
        this.route('leadClimbing', {path: 'lead-climbing'});
        this.route('speedClimbing', {path: 'speed-climbing'});
        this.route('leadClimbingTurret', {path: 'lead-climbing-turret'});
        this.route('mattresses', {path: 'mattresses'});
    });
    this.resource('eng.factory', {path: 'factory'}, function(){
        this.route('panelType', {path: 'panel-type'});
        this.route('exteriorFinishing', {path: 'exterior-finishing'});
        this.route('buildingSystem', {path: 'building-system'});
        this.route('design');
    });
    this.resource('eng.holds', {path: 'holds'}, function(){
        this.route('importClimbingVolumes', {path: 'import-climbing-volumes'});
    });
    this.resource('eng.team', {path: 'team'}, function(){
        this.route('alePenna', {path: 'ale-penna'});
    });
    this.resource('eng.photoGallery', {path: 'photo-gallery'}, function(){
        this.route('evolutionClimbing', {path: 'evolution-climbing'});
        this.route('pragelatoBoulder', {path: 'pragelato-boulder'});
    });
    this.route('contacts');
    //error catch all
    this.route('404', { path: '*:' });

});

这是我的linkTo的一个例子:

{{#linkTo eng.aboutUs class="nav ck_0"}}About us{{/linkTo}}

【问题讨论】:

    标签: ember.js handlebars.js


    【解决方案1】:

    是的,最后我发现我只需要在 linkTo 助手中的引号之间写下路由名称,如下所示:

    {{#linkTo 'eng.aboutUs' class="nav ck_0"}}About us{{/linkTo}}
    

    我不知道为什么以前没有引号而现在没有,可能在最新的 Ember 中发生了一些变化......

    【讨论】:

      【解决方案2】:

      现在不推荐使用 linkTo 帮助程序,您应该使用 link-to 以避免将来出现问题。

      例如{{#link-to 'post' post}}View post{{/link-to}}

      【讨论】:

      • 好的,你能解释一下旧的linkTo和新的link-to helper之间的区别吗?
      • 据我所知,它们的工作方式完全相同。我想它只是为了命名约定而重命名。
      • 我必须按如下方式编写我的助手:{{#link-to 'post'}}View Post{{/link-to}}
      猜你喜欢
      • 2019-08-10
      • 2014-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多