我得到 include is not a function 错误,并且已经 record.id 无法识别 VS Code 上的 .includes()
我不知道问题出在哪里?
import React, { Component } from 'react'
import axios from "axios"
export default class Tablo extends Component {
constructor(props){
super(props)
this.state={
records:[],
id:1
}
}
render() {
return (
<div>
{
this.state.records.filter(record => record.id.includes(this.state.id))
.map(rec => (
<li> {rec.shop}</li>
))
}
</div>
)
}
componentDidMount() {
axios.get('http://localhost:8080/kayitlar').then(res => {
console.log(res);
this.setState({records:res.data});
});
}