gpt4 book ai didi

javascript - 在 ExtJS 的组件中添加 onclick 函数?

转载 作者:行者123 更新时间:2023-11-28 15:08:01 25 4
gpt4 key购买 nike

我想向超链接添加一个点击监听器,以从 Controller 调用该函数:

查看:

 {
xtype: 'component',
autoEl:{
html: '<a href="#">Forgot password?</a>',
listeners: {
click: 'forgotPassword'
}}
}

Controller :

forgotPassword: function () {
alert('HHHH');
this.getView().destroy();
}

但是不起作用?

最佳答案

  1. 您的监听器不应位于 autoEl 对象中。
  2. element: 'el' 添加到您的监听器。

例如:

{
xtype: 'component',
html: '<a href="#">Forgot password?</a>'
listeners: {
element: 'el',
click: 'forgotPassword'
}
}

https://fiddle.sencha.com/#fiddle/1clt

关于javascript - 在 ExtJS 的组件中添加 onclick 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38039030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com