IframePageView.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <iframe :id="id" :src="url" frameborder="0" width="100%" :height="height" scrolling="auto"></iframe>
  3. </template>
  4. <script>
  5. import { mixinDevice } from '@/utils/mixin.js'
  6. export default {
  7. name: 'IframePageContent',
  8. inject: ['closeCurrent'],
  9. mixins: [mixinDevice],
  10. data() {
  11. return {
  12. url: '',
  13. id: '',
  14. height: '',
  15. }
  16. },
  17. created() {
  18. this.goUrl()
  19. },
  20. methods: {
  21. goUrl() {
  22. let url = this.$route.meta.url
  23. this.id = this.$route.path
  24. if (this.isMobile()) {
  25. this.height = 800
  26. } else {
  27. this.height = document.documentElement.clientHeight - 100
  28. }
  29. console.log('------url------' + url)
  30. if (url !== null && url !== undefined) {
  31. if (url) {
  32. url = url.replace('/system', '')
  33. if (url.indexOf('.html') === -1) {
  34. //地址不以.html结尾的,需要重新构造url
  35. let urlArr = url.split('/')
  36. url = '/' + urlArr[1] + '/' + urlArr[2] + '/' + urlArr[2] + '.html?t=' + urlArr[3]
  37. }
  38. url = document.location.protocol + '//' + window.location.host + url
  39. }
  40. this.url = url
  41. }
  42. },
  43. },
  44. }
  45. </script>
  46. <style></style>