Meteor React组件onClick事件在IE中不起作用

Meteor React component onClick event not working in IE

本文关键字:IE 不起作用 事件 React 组件 onClick Meteor      更新时间:2023-09-26

我目前正在使用React开发一个小型Meteor应用程序,遇到了一个问题(似乎是一夜之间,可能是更新引起的?),我的onClick事件在IE中没有启动,但在其他浏览器中运行良好。

请参阅以下示例-

if (Meteor.isClient) {
    Meteor.startup(function ()
    {
        React.render(<TestComponent />, document.getElementById("render-target"));
    });
}
if (Meteor.isServer) {
    Meteor.startup(function () {
        // code to run on server at startup
    });
}

TestComponent = React.createClass({
    showAlert()
    {
        alert("On click!");
    },
    render()
    {
        return (
            <div><button onClick={this.showAlert}>Click Me</button></div>
          )
    }
});

代码只需在页面上加载一个按钮,并在单击时显示警报。这在Chrome/Firefox中运行良好,但在Internet Explorer中不会显示警报。有人能解释一下吗?

更新:

最新版本的React似乎出现了一些问题。看起来修复程序将于明天发货:

https://github.com/facebook/react/issues/5324