我在 StackOverflow 上到处搜索,看到了类似的问题,但没有找到有效的解决方案。想知道是否有人有有效的解决方案?我正在 localhost:3000 上开发一个 create react 应用程序,并尝试通过我的 Apollo Client 访问另一个站点上的 URI(我正在使用https://developer.github.com/v4/explorer/进行测试)。
我已将 'no-cors' 的 fetchOptions 模式添加到我的新 ApolloClient 实例中,但我的控制台中仍然出现 CORS 错误。我的整个 index.js 文件如下:
import React from 'react';
import ReactDOM from 'react-dom';
import { ApolloProvider } from 'react-apollo';
import { ApolloClient, HttpLink, InMemoryCache } from 'apollo-boost';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
const client = new ApolloClient({
link: new HttpLink({ uri: 'https://developer.github.com/v4/explorer/' }),
fetchOptions: {
mode: 'no-cors',
},
cache: new InMemoryCache()
});
const …Run Code Online (Sandbox Code Playgroud) 我正在为 React 项目使用 React Player npm install。视频播放器处于模态。当模态关闭时如何阻止它播放?是否有一种ReactPlayer.stop()或一种ReactPlayer.pause()类型的功能可以添加到我的hideModal函数中?
<Modal show={this.state.show} handleClose={this.hideModal} >
<ReactPlayer url='https://www.youtube.com/watch?v=ysz5S6PUM-U' width='100%'
height='100%' />
</Modal>
Run Code Online (Sandbox Code Playgroud)