We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDE在线版
import { useEffect, useState } from 'react'; export default function App() { const [instruct, setInstruct] = useState([0, 1, 2]); const increase = () => { console.log('lastArr', instruct); const length = instruct.length - 1; const _instruct = instruct.slice(); const target = ++_instruct[length]; console.log('现在的问题:', target); _instruct.push(target); setInstruct(_instruct); console.log('currentArr', _instruct); }; return ( <div> <button onClick={increase}>Click</button> </div> ); }
这里的 ++[0,1,2][2] 看样子会修改原数组的中2 索引的值然后在赋值给 target
2
The text was updated successfully, but these errors were encountered:
倒不是是react 中的问题 数组中原本就不能这样使用
Sorry, something went wrong.
xiaochengzi6
No branches or pull requests
IDE在线版
这里的 ++[0,1,2][2] 看样子会修改原数组的中
2
索引的值然后在赋值给 targetThe text was updated successfully, but these errors were encountered: