简体   繁体   English

使用Babel的React.JS不会触发onClick

[英]React.JS with Babel is not triggering onClick

This for me is pure madness. 对我来说这纯属疯狂。 Basic react.js example with babel. Babel的基本react.js示例

import React from 'react';
import {render} from 'react-dom';
export default class MyComponent extends React.Component {
   constructor(props){
      super(props);
      this.save= this.save.bind(this);
   }
   render () {
      return  (<button onClick={this.save}>collection stuff</button>);
   }

  save(ev){
     alert("stuff");
  }
}

The save event is never triggered . The save event is never triggered All i have in my console is this: 我在控制台中所拥有的就是:

getEventTarget.js:23 Uncaught TypeError: Cannot read property 'target' of undefined getEventTarget.js:23未捕获的TypeError:无法读取未定义的属性“ target”

Did someone else experience this? 有人遇到过吗? my brain hurts right now. 我的大脑现在很痛。

Seems like React.js and Scritaculous/Prototype.js don`t get along. 好像React.js和Scritaculous / Prototype.js似乎不融洽。 The project had a lot of legacy code, after removing prototype everything worked. 在删除原型后,该项目具有大量的遗留代码,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM