我正在做樹結(jié)構(gòu)。我需要添加數(shù)據(jù)并想要?jiǎng)h除、編輯和搜索當(dāng)我在該數(shù)據(jù)存儲(chǔ)新變量之前將新數(shù)據(jù)推入數(shù)組時(shí),我遇到了一個(gè)錯(cuò)誤TypeError: treeData.push is not a function如何將該數(shù)據(jù)設(shè)置到新的變量中以及如何推送數(shù)組......添加.js 文件:import React, { useState} from 'react';import { TextField} from '@fluentui/react/lib/TextField';import { DefaultButton, PrimaryButton, Stack, IStackTokens} from '@fluentui/react';import './styles.css'const TextFieldBasicExample = (props) => { const [newItemValue, setNewItemValue] = useState({ title: '' }); console.log('onchange', newItemValue); const handleChange = (e) => { setNewItemValue({ [e.target.name]: e.target.value, }); } const _insert = (event) => { console.log('onclick', newItemValue); props.callback(newItemValue); // setNewItem({ // [event.target.name]:'' // }) } return ( < Stack horizontal > < Stack className = "add-inp" > < TextField label = "Add Item" name = "title" onChange = { handleChange } /> < span id = "error_name" > < /span> < PrimaryButton text = "Add" className = "add-btn" onClick = { _insert } /> < /Stack> < /Stack> );};export default TextFieldBasicExample
我在將新數(shù)據(jù)推送到數(shù)組時(shí)遇到錯(cuò)誤
一只斗牛犬
2023-11-11 16:04:58