Game.vue 618 字节
Newer Older
前端开发者-李墨尘's avatar
前端开发者-李墨尘 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<template>
  <div :id="containerId" v-if="downloaded" />
  <div class="placeholder" v-else>
    Downloading...
  </div>
</template>
<script>
export default {
  name: 'Game',
  data: function () {
    return {
      downloaded: false,
      gameInstance: null,
      containerId: 'game-container'
    }
  },
  async mounted () {
    const game = await import('../game/game')
    this.downloaded = true
    this.$nextTick(() => {
      this.gameInstance = game.launch(this.containerId)
    })
  },
  destroyed () {
    this.gameInstance.destroy(false)
  }
}
</script>
<style scoped></style>