IframePageView.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <iframe :id="id" :src="url" frameborder="0" width="100%" height="800px" scrolling="auto"></iframe>
  3. </template>
  4. <script>
  5. import Vue from 'vue'
  6. import { ACCESS_TOKEN } from "@/store/mutation-types"
  7. import PageLayout from '../page/PageLayout'
  8. import RouteView from './RouteView'
  9. export default {
  10. name: "IframePageContent",
  11. inject:['closeCurrent'],
  12. data () {
  13. return {
  14. url: "",
  15. id:""
  16. }
  17. },
  18. created () {
  19. this.goUrl()
  20. },
  21. updated () {
  22. this.goUrl()
  23. },
  24. watch: {
  25. $route(to, from) {
  26. this.goUrl();
  27. }
  28. },
  29. methods: {
  30. goUrl () {
  31. let url = this.$route.meta.url
  32. let id = this.$route.path
  33. this.id = id
  34. //url = "http://www.baidu.com"
  35. console.log("------url------"+url)
  36. if (url !== null && url !== undefined) {
  37. this.url = url;
  38. /*update_begin author:wuxianquan date:20190908 for:判断打开方式,新窗口打开时this.$route.meta.internalOrExternal==true */
  39. if(this.$route.meta.internalOrExternal != undefined && this.$route.meta.internalOrExternal==true){
  40. this.closeCurrent();
  41. //外部url加入token
  42. let tokenStr = "${token}";
  43. if(url.indexOf(tokenStr)!=-1){
  44. let token = Vue.ls.get(ACCESS_TOKEN);
  45. this.url = url.replace(tokenStr,token);
  46. }
  47. window.open(this.url);
  48. }
  49. /*update_end author:wuxianquan date:20190908 for:判断打开方式,新窗口打开时this.$route.meta.internalOrExternal==true */
  50. }
  51. }
  52. }
  53. }
  54. </script>
  55. <style>
  56. </style>