【发布时间】:2019-08-16 21:21:54
【问题描述】:
我正在从 API 的端点获取数据(我正在使用 ReactJS)。 Cors 已启用。 我的问题是,当我尝试显示图像(使用 or )时,Cors 阻止了对图像的访问。
我尝试添加 crossOrigin='anonymous' ,但没有成功。
我没有任何访问服务器的权限。
我可以获取并显示所有其他数据。
我有点绝望,所以如果你有什么想法可以帮助我展示我的图像,那就太好了!!! :)
我如何获取我的数据:
fetch(myURL)
.then(response => response.json())
.then(data => this.setState({ items: data.items }))
.catch(error => {
console.log(error);
this.setState({
error: true
});
});
【问题讨论】: