nav-view-vessel.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="view-vessel">
  3. <div class="a-view" v-for="tab in $root.viewList" :key="tab.id" :class="tab == $root.nativeTab ? 'a-view-native' : null">
  4. <!-- vue视图 -->
  5. <template v-if="tab.view">
  6. <component :is="tab.view" class="vue-com-view" v-if="tab.isNeedLoad"></component>
  7. </template>
  8. <!-- iframe视图 -->
  9. <template v-else>
  10. <iframe :src="tab.url" :id=" 'iframe-' + tab.id " v-if="tab.isNeedLoad" @load="onloadIframe(tab.id)"></iframe>
  11. </template>
  12. </div>
  13. <!-- tab被拖拽时的遮罩(下托拽:悬浮打开) -->
  14. <div class="shade-fox" v-if="$root.isDrag"
  15. @dragover="$event.preventDefault();"
  16. @drop="$event.preventDefault(); $event.stopPropagation(); $root.xfTab($root.dragTab); $root.closeTab($root.dragTab);">
  17. <span style="font-size: 24px;">拖拽至此:悬浮打开</span>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. module.exports = {
  23. data() {
  24. return {
  25. }
  26. },
  27. methods: {
  28. // iframe加载完毕后清除其背景 loading 图标
  29. onloadIframe: function(iframeId) {
  30. // console.log('iframeId', iframeId);
  31. var iframe = document.querySelector('#iframe-' + iframeId);
  32. if(iframe != null) {
  33. iframe.parentElement.style.backgroundImage='none';
  34. }
  35. },
  36. },
  37. created() {
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. .view-vessel{height: 100%; position: relative; border: 0px #000 solid;}
  43. .a-view{width: 100%; height: 100%; background-color: #EEE; background: url(../index/admin-loading.gif) no-repeat center 50%; position: absolute; }
  44. .a-view{opacity: 0; transition: all 0.2s;}
  45. .a-view-native{z-index: 100000; opacity: 1;}
  46. .a-view>iframe{width: 100%; height: 100%; border: 0px #000 solid;}
  47. .a-view>.vue-com-view{width: 100%; height: 100%; overflow: auto; background-color: #EEE;}
  48. /* .iframe-no-scroll{width: calc(100% + 22px); } */
  49. </style>