这个 twiddle 在 Chrome 中工作但在 firefox 中不工作
https://ember-twiddle.com/aa8196622fcd6b8f6ce441c8a9174600?openFiles=controllers.application.js%2C
我发现了类似的问题 here , 但没有理由不工作。
我使用的是 Firefox v61.0.1 和 Chrome v67.0.3396.99
//application.hbs
<div class="box">
<button type="button" class="close note-close" aria-label="Close">
<span aria-hidden="true" class="close" {{action 'testAction'}}>×</span>
</button>
</div>
//application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
testAction: function() {
alert("Close Button Working");
}
}
});
如果您在 Chrome 中单击关闭按钮,它会触发 Controller 中的 testAction。但是在 firefox 中没有错误,但没有在 Controller 中触发我的 testAction。
最佳答案
单击按钮元素的嵌套元素不起作用。
将您的操作添加到按钮元素并使用 closure-actions (点击)
<button type="button" class="close note-close" aria-label="Close" onclick={{action 'testAction'}}>
<span aria-hidden="true" class="close note-close">×</span>
</button>
关于javascript - FireFox 中未触发 Ember 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51532205/