44096267d9b6cf0dda458217b266a284a8ac0cd4.svn-base 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. //-----------------------------------------------------------------------------------------
  38. //url支持通过 ${token}方式传递当前登录TOKEN
  39. let tokenStr = "${token}";
  40. if(url.indexOf(tokenStr)!=-1) {
  41. let token = Vue.ls.get(ACCESS_TOKEN);
  42. this.url = url.replace(tokenStr, token);
  43. } else {
  44. this.url = url
  45. }
  46. //-----------------------------------------------------------------------------------------
  47. /*update_begin author:wuxianquan date:20190908 for:判断打开方式,新窗口打开时this.$route.meta.internalOrExternal==true */
  48. if(this.$route.meta.internalOrExternal != undefined && this.$route.meta.internalOrExternal==true){
  49. this.closeCurrent();
  50. window.open(this.url);
  51. }
  52. /*update_end author:wuxianquan date:20190908 for:判断打开方式,新窗口打开时this.$route.meta.internalOrExternal==true */
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style>
  59. </style>