📌  相关文章
📜  在线将类转换为功能组件 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:15.933000             🧑  作者: Mango

代码示例3
import React, { Component } from "react";
import { InputGroup, FormControl, Input } from "react-bootstrap";

class SimpleKeyEvent extends Component {
  constructor() {
    super();
    this.state = {
      name: "React-bootstrap key enter event"
    };
    this.onKeyUp = this.onKeyUp.bind(this);
  }

  onKeyUp(event) {
    if (event.charCode === 13) {
      this.setState({ inputValue: event.target.value });
    }
  }

  render() {
    const { inputValue } = this.state;

    return (
      

Input value is : {inputValue}
); } } export default SimpleKeyEvent;