无法在“ DOMWindow”上执行“ postMessage”

时间:2019-02-20 06:38:01

标签: reactjs youtube-api react-player

我使用react-player并得到一个错误

<ReactPlayer
          width="100%"
          height="100%"
          autoPlay={false}
          url="https://www.youtube.com/embed/fAGToLx-cek"
          config={
            youtube: {
              playerVars: { showinfo: 1, controls: 1 },
            },}
        />

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://localhost').

生成的代码iframe

<iframe frameborder="0" allowfullscreen="1" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" title="YouTube video player" width="100%" height="100%" src="https://www.youtube.com/embed/fAGToLx-cek?autoplay=0&amp;mute=0&amp;controls=1&amp;origin=https%3A%2F%2Flocalhost&amp;playsinline=1&amp;showinfo=1&amp;rel=0&amp;iv_load_policy=3&amp;modestbranding=1&amp;enablejsapi=1&amp;widgetid=1" id="widget2"></iframe>

0 个答案:

没有答案