document.domain + iframe解决跨域问题

  • 不喜勿喷,请提意见,谢谢!!!!

在项目中遇到iframe嵌入页面处于同一主域下,但在不同子域下解决跨域问题;

列如:

<template> 
 <div class="div_info">
     <iframe
	     :src="iframeURL"
	      id="mobsf"
	      height="100%"
	      width="100%"
	      scrolling="no"
	      frameborder="0"
	      class="iframe_style"
      ></iframe>
   </div>
</template>
<script> 
import website from "@/config/website";
export default {
  name: "iframe",
  data() {
    return {
      iframeURL: "",
    };
  },
  components: { 
  },
  computed: {},
  updated() {},
  mounted() {
    //通过document.domain + iframe解决跨域问题
    document.domain = "xinnuo.com";
    this.iframeURL= website.iframeURL;
  },
  methods: {},
};
</script>
<style lang="sass" scoped>
</style>
Logo

鸿蒙生态一站式服务平台。

更多推荐