<template>
  <div class="wh-full">
    <div id="container"></div>
  </div>
</template>
<script setup lang="ts">
import { watch, onMounted } from 'vue';
import { renderAsync } from 'docx-preview';
const props = defineProps({
  url: {
    type: String,
    default: ''
  }
});

async function init() {
  const f = await fetch(props.url);
  const ab = await f.arrayBuffer();
  const doc = document.getElementById('container');
  if (doc) {
    renderAsync(ab, doc);
  }
}

watch(
  () => props.url,
  () => {
    init();
  }
);
onMounted(() => {
  init();
});
</script>
<style></style>
