保存带有换行符的文本域,MERNStack。
创始人
2024-11-22 07:01:49
0
  1. 创建一个react组件来呈现文本域,并在State中存储文本域中的值。
import React, { Component } from 'react';

class TextArea extends Component {
  constructor(props) {
    super(props);

    this.state = {
      value: ''
    };

    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(event) {
    this.setState({ value: event.target.value });
  }

  render() {
    return (