此获取请求:
var url = 'api/assetName/?id='+id;
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
credentials: 'include',
body: JSON.stringify({
ids: vehiclesT
})}
).then(data => {
return data.json();
}).then( json => {
console.log(json);
console.log(json);
this.setState({
vehicles: json
});
});
抛出此错误:
Uncaught (in promise) TypeError: Cannot read property 'setState' of undefined
基本上为什么会这样,我该如何解决?
谢谢,Ed。