Vue に統合する

まずインストールと基本的な使い方を参照してください。以下は Vue を使い、高さを明示したコンテナーに Univer Pdfs をマウントする例です。

統合手順

  1. onMounted で Univer を初期化します。
  2. onBeforeUnmount で Univer を破棄します。

サンプルコード

Vue
<script setup lang="ts">import { onBeforeUnmount, onMounted, ref } from 'vue'import { UniverLicensePlugin } from '@univerjs-pro/license'import { UniverPdfsPlugin } from '@univerjs-pro/pdfs'import { UniverPdfsUIPlugin } from '@univerjs-pro/pdfs-ui'import PdfsUIjaJP from '@univerjs-pro/pdfs-ui/locale/ja-JP'import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import { FUniver } from '@univerjs/core/facade'import DesignjaJP from '@univerjs/design/locale/ja-JP'import { UniverUIPlugin } from '@univerjs/ui'import UIjaJP from '@univerjs/ui/locale/ja-JP'import '@univerjs/design/lib/index.css'import '@univerjs/ui/lib/index.css'import '@univerjs-pro/pdfs-ui/lib/index.css'import '@univerjs-pro/pdfs/facade'const containerRef = ref<HTMLDivElement | null>(null)let univerInstance: Univer | undefinedonMounted(() => {  const container = containerRef.value  if (!container) return  const univer = new Univer({    locale: LocaleType.JA_JP,    locales: {      [LocaleType.JA_JP]: mergeLocales(        DesignjaJP,        UIjaJP,        PdfsUIjaJP,      ),    },  })  univer.registerPlugin(UniverLicensePlugin, {    license: 'your license.txt',  })  univer.registerPlugin(UniverUIPlugin, { container })  univer.registerPlugin(UniverPdfsPlugin)  univer.registerPlugin(UniverPdfsUIPlugin)  const univerAPI = FUniver.newAPI(univer)  univerAPI.createPdf({ name: 'Untitled PDF' })  univerInstance = univer})onBeforeUnmount(() => univerInstance?.dispose())</script><template>  <div ref="containerRef" style="height: 600px" /></template>

このガイドはいかがですか?

© 2026 DreamNum Co., Ltd.