2017-03-06 73 views

回答

1

我不能完全肯定,从你的描述,但它听起来像是要引起一些动作加载应用程序时发生。您可以尝试使用ready(),如入门指南中所述。

http://enyojs.com/docs/latest/developer-guide/getting-started/creating-and-building-an-app.html

另一个选择是到东西添加到您的初始应用rendered执行你的buttonTapped()方法。

rendered: function() { 
    this.inherited(arguments); 
    this.doSomething(); 
} 
+0

谢谢回答,你的权利,我需要调用行动应用程序加载之后。我使用ready()函数,但在将其与组件绑定时遇到问题。为了更好的理解,我改变了问题 – Acid

+0

你可以给init应用程序渲染的例子吗? – Acid

0

我解决了它。我重写这样的代码

 {kind: IconButton, src: '@../../assets/info.png', ontap: "buttonTapped"}, 

create: function() { 
       this.inherited(arguments); 
       this.ServiceReq(); 
      }, 

    buttonTapped: function(inSender, inEvent) { 

     this.ServiceReq(); 
     return; 

    }, 

    ServiceReq: function() 
     { console.log('Clicked');} 

但我不知道这是一个很好的解决方案,但它工作

+0

正如我在我的回答中提到的,你应该使用[rendered()](http://enyojs.com/docs/latest/#/kind/enyo/Control/Control:rendered)。在将组件呈现到页面上之前调用'create()',这样就不会有可以响应的控件。我更新了我的答案以显示“rendered()” – Pre101