我在 react js 中使用 map 時(shí)遇到錯(cuò)誤。此問(wèn)題的解決方案可能是什么?代碼如下:Uncaught TypeError: this.state.salaryDetails.map is not a functionimport React, { Component } from 'react';import httpBrowsing from './../../../utils/httpBrowsing';import { NativeSelect, FormControl } from '@material-ui/core'export class Salary extends Component {constructor() { super(); this.state = { salaryDetails: '', data: { employeeName: '', year: '', month: '' } }}handleChange = (e) => { const { name, value } = e.target; this.setState((pre) => ({ data: { ...pre.data, [name]: value, employeeName: this.state.salaryDetails.filter((item) => item[name] === value) } }))}componentDidMount() { httpBrowsing.get('/addemployee', true) .then((data) => { this.setState({ salaryDetails: data.data, }) }) .catch(err => { console.log("error", this.state); debugger; })}我嘗試使用來(lái)自數(shù)據(jù)庫(kù)的選項(xiàng),使用本機(jī)選擇的材料UI,但顯示錯(cuò)誤.可能是什么問(wèn)題 ?問(wèn)題可能是什么?我該如何解決問(wèn)題?請(qǐng)為我提供解決方案。
在 react 中使用 Array.map.js
蕪湖不蕪
2022-08-04 17:59:40