import React, {Component} from 'react';
import {render} from 'react-dom';
import Button from 'react-bootstrap/Button'
class InputRead extends Component {
constructor() {
return { user: '' };
inputChange(e) {
this.setState({user:e.target.value});
clearAndFocus() {
this.setState({user:''},()=>{
this.refs.thisInput.focus();
render() {
return (
<Button onClick={this.clearAndFocus.bind(this)}>
</Button>
<input ref="thisInput" value={this.state.user} onChange={this.inputChange.bind(this)}/>
export default InputRead;
构造函数中不能使用return语句,否则以为构造函数中需要添加render()方法
3、解决办法
import React, {Component} from 'react';
import {render} from 'react-dom';
import Button from 'react-bootstrap/Button'
class InputRead extends Component {
constructor(props) {
//return { user: '' };
super(props);
this.state = { user: '' };
inputChange(e) {
this.setState({user:e.target.value});
clearAndFocus() {
this.setState({user:''},()=>{
this.refs.thisInput.focus();
render() {
return (
<Button onClick={this.clearAndFocus.bind(this)}>
</Button>
<input ref="thisInput" value={this.state.user} onChange={this.inputChange.bind(this)}/>
export default InputRead;
1、错误描述2、错误原因import React, {Component} from 'react';import {render} from 'react-dom';import Button from 'react-bootstrap/Button'class InputRead extends Component { constructor() { return ...
node + mysql;
今天写demo的时候,发现代码报错
TypeError
: res.
render
is not a
function
,但是自己自测了在不适用mysql查询数据时res.
render
()方法是可用的,但在不适用mysql数据时res.
render
()并不会出问题。直接上代码:
var express = require('express');
var rou...