无法从视图中调用路由器操作

Cannot call a router action from the view

这是我的路线:

this.route('produits', function(){ 
  this.route('new');
  this.route('edit', { path: '/:produit_id/edit' }, function() {
    this.route('documents');
  });
});

这是我在 routes/produit/edit/documents.js 中的操作:

actions: {
    refreshRoute() {
      this.refresh();
    }   
}

在document.hbs中,我一使用{{action refreshRoute}},就会出现以下错误:Assertion Failed: An action named 'refreshRoute' was not found in (generated produits.edit.documents controller)

为什么在 CRUD 视图中使用相同的语法却不起作用?

您已经在您的路线中定义了您的动作。要到达路线操作,您可以使用 ember-route-action-helper。而不是 {{action 'refreshRoute'}},您应该使用 {{route-action 'refreshRoute'}} 否则它将在控制器中查找操作。