3 回答
TA贡献1869条经验 获得超4个赞
我认为react-dom没有useState,所以将文件的顶部更改为:
import React, { useState } from "react"
import './App.css';
function App(props) {
const [click, setClick] = useState(0);
const handleChange = e => {
console.log(e.target.value)
}
const handleClick = e => {
console.log(e.target)
}
return (
<div className="App">
Value<input type="text" onChange={ handleChange }/>
<select>
<option>F to C degrees</option>
<option>C to F degrees</option>
</select>
<button onClick={handleClick}>Go</button>
</div>
);
}
export default App;
TA贡献1829条经验 获得超13个赞
import React from "react"
const App = (props)=>{
const [click, setClick] = useState(0);
const handleChange = e => {
console.log(e.target.value)
}
const handleClick = e => {
console.log(e.target)
}
return (
<div className="App">
Value<input type="text" onChange={ handleChange }/>
<select>
<option>F to C degrees</option>
<option>C to F degrees</option>
</select>
<button onClick={handleClick}>Go</button>
</div>
);
}
export default App;
添加回答
举报