我有这个 React Bootstrap 类,我知道如何在单击按钮时捕获它的值?如何在文档中看到这一点?
花了很多时间...
这是我在控制台中带有警告的代码警告:React 无法识别inputRefDOM 元素上的道具。如果您有意希望它作为自定义属性出现在 DOM 中,请将其拼写为小写inputref。如果您不小心从父组件传递了它,请将其从 DOM 元素中删除。:
import React, { Component } from 'react';
import { Button, Form } from 'react-bootstrap';
import '../../styles/feedback-send.css';
class FeedbackSend extends Component {
constructor(props) {
super(props);
this.inputNode = '';
}
onSubmit() {
const data = this.inputNode.value;
console.log(data);
}
render() {
return (
<Form.Group className="m-0">
<Form.Control
className="textFeedback"
as="textarea"
rows="3"
placeholder="feedback"
inputRef={(node) => { this.inputNode = node; }}
type="text"
/>
<Button
className="btnFormSend"
variant="outline-success"
onClick={this.onSubmit} …Run Code Online (Sandbox Code Playgroud)