index.vue 1.24 KB
<template>
  <div class="adapter-home" id="adapter-frame" ref="adapter-frame"></div>
</template>

<script>
import { Postmate } from 'glsx-common'
export default {
  name: 'GLExternal',
  data() {
    return {
      container: null
    }
  },
  mounted() {
    this.container = this.$refs['adapter-frame']
    this.create(this.$router.currentRoute.meta.url)
  },

  methods: {
    create(url) {
      this.container.innerHTML = ''
      new Postmate({
        container: this.container,
        url,
        name: 'adapter-frame',
        classListArray: ['adapter-frame'],
        data: () => 'aaa'
      }).then(child => {
        child.get('height').then(height => {
          child.frame.setAttribute('scrolling', 'no')
          child.frame.style.height = `${height}px`
        })
        child.call('push', { src: this.src })
        child.on('route-to', (id, params) => {
          console.log(params)
          this.$history.push(id)
        })
      })
    }
  }
}
</script>
<style>
.adapter-frame {
  width: 100%;
  min-height: calc(100vh - 90px);
  border: 0;
  overflow-y: hidden;
  box-sizing: border-box;
  /* position: absolute; */
  transition: all 0.48s ease;
}
</style>
<style scoped lang="scss">
.app-view-box {
  padding: 0 !important;
}
</style>