gpt4 book ai didi

javascript - FireFox 中未触发 Ember 操作

转载 作者:行者123 更新时间:2023-11-29 23:18:49 25 4
gpt4 key购买 nike

这个 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'}}>&times;</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">&times;</span>
</button>

关于javascript - FireFox 中未触发 Ember 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51532205/

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