【发布时间】:2016-09-08 11:37:37
【问题描述】:
不确定是我做错了什么还是这是一个错误,
我有一个运行 vue 路由器的简单 web vue.js 页面,主页上有一个 iframe。如果没有页面上的 iframe,它在使用 v-link 在页面之间移动时可以正常工作,但是使用 iframe 在尝试在页面之间移动时出现此跨域错误。
vue.common.js?e881:1140 Uncaught SecurityError: Blocked a frame with origin "http://localhost:8080" from accessing a frame with origin "http://interactr-dev.s3-website-eu-west-1.amazonaws.com". Protocols, domains, and ports must match.
我不确定这是否与它有关,但 iframe 也在运行 Vue(尽管它们没有绑定到同一个 id)。
如果这是 Vue 的错误或我正在做的方式,有人会否吗?
【问题讨论】:
-
这是一个跨源问题:您似乎正在混合来自本地服务器和亚马逊 s3 服务器的内容。
-
是的,iframe 的 src 在 s3 上。 iframe 加载并播放得很好,直到您使用 vue 路由器触发页面更改之前它不会显示错误,不确定 Vue 在页面更改时是否尝试在 iframe 中执行任何操作,这就是抛出跨域的原因错误
-
我不知道这是否相关,但last release of Vue (1.0.24) 说:
fixed regression in 1.0.23 that breaks app if the page contains iframes with different origins -
啊,就是这样。主页面运行的是最新版本的 Vue,但 iframe 运行的是 1.0.21,我在 iframe 中更新了 Vue 的版本,问题就解决了。
标签: javascript vue.js vue-router