场景:
网站iframe内嵌vue项目
原因:
iframe框架跟内嵌网页跨域
例如
网站域名:http://test.com iframe内嵌域名http://casey.test2.com则会出现上边报错
解决方法
vue项目app.vue文件<script>下设置document.domain = 'test.com' // 设置vue项目主域跟网站主域一致
延伸:
如果网站域名多级例如http://aaa.test.com iframe内嵌域名http://casey.aaa.test2.com则会出现上边报
同理:vue项目app.vue文件<script>下设置document.domain = 'aaa.test.com' // 设置vue项目主域跟网站主域一致
扫描二维码关注公众号,回复:
8633421 查看本文章
![](/qrcode.jpg)