現(xiàn)在在用react-router做一個(gè)SPA應(yīng)用,也存在跨域問(wèn)題,但是我在網(wǎng)上看見(jiàn)別人有的web頁(yè)面可以請(qǐng)求到,是不是別人自己用服務(wù)器做處理了?項(xiàng)目地址fetch(getLatestNews(),{ method: 'GET', mode: 'cors', }) .then((response) => { console.log(response) if (response.ok) { return response.json() } }) .then((responseData) => { this.setState({ isLoaded: true, }) }) .catch(() => { this.setState({ isLoaded: false, }) });警告Fetch API cannot load http://news-at.zhihu.com/api/... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.xboxyan.com' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
怎么解決fetch的跨域問(wèn)題?現(xiàn)在在用react-router做一個(gè)SPA
MMTTMM
2018-10-18 13:11:47