请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

constructor报错

import React from ‘react’;
//this.state是组件的状态
function App() {
constructor(props) {
super(props);
this.state={
inputValue:‘hello’,
list:[]
};
};

return (


提交


  • 学英语
  • learning react


);
}

export default App;
为什么会报错图片描述

正在回答 回答被采纳积分+3

1回答

Dell 2020-06-07 21:44:29

function 函数不能写constructor,你改成class

0 回复 有任何疑惑可以回复我~
  • 改成Class也报错
    回复 有任何疑惑可以回复我~ 2020-06-18 09:51:28
  • Dell 回复 诸葛钢镚 #2
    class 之后你要写render
    回复 有任何疑惑可以回复我~ 2020-06-20 17:24:20
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信