我在reactJs中创建了come组件,由2个按钮处理每个onClick函数组成,但是当我运行代码“ myfunction is not defined”时出现错误。我想在按钮触发时将页面重定向到指定的地址。我的代码有什么问题?
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
class MainMenu extends React.Component {
constructor(props){
super(props);
this.slotClick = this.slotClick.bind(this);
this.freqClick = this.freqClick.bind(this);
}
slotClick = (e) => {
e.preventDefault();
}
freqClick = (e) => {
e.preventDefault();
}
render() {
return (
<div>
<input type="button" value="By Time Slot" onClick={ slotClick } />
<input type="button" value="By Frequency" onClick={ freqClick } />
</div>
)
}
}
export default MainMenu;
慕神8447489
慕码人8056858
相关分类