Angular に統合する

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

統合手順

  1. ngAfterViewInit で Univer を初期化します。
  2. ngOnDestroy で Univer を破棄します。

サンプルコード

TypeScript
import type { AfterViewInit, ElementRef, OnDestroy } from '@angular/core'import { Component, ViewChild } from '@angular/core'import { UniverLicensePlugin } from '@univerjs-pro/license'import { UniverSlidesPlugin } from '@univerjs-pro/slides'import { UniverSlidesUIPlugin } from '@univerjs-pro/slides-ui'import SlidesUIjaJP from '@univerjs-pro/slides-ui/locale/ja-JP'import SlidesjaJP from '@univerjs-pro/slides/locale/ja-JP'import { LocaleType, mergeLocales, Univer, UniverInstanceType } from '@univerjs/core'import DesignjaJP from '@univerjs/design/locale/ja-JP'import { UniverDocsPlugin } from '@univerjs/docs'import { UniverDocsUIPlugin } from '@univerjs/docs-ui'import DocsUIjaJP from '@univerjs/docs-ui/locale/ja-JP'import { UniverDrawingPlugin } from '@univerjs/drawing'import { UniverRenderEnginePlugin } from '@univerjs/engine-render'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/docs-ui/lib/index.css'import '@univerjs-pro/slides-ui/lib/index.css'@Component({  selector: 'app-univer',  standalone: true,  template: '<div #container style="height: 600px"></div>',})export class UniverComponent implements AfterViewInit, OnDestroy {  @ViewChild('container') containerRef!: ElementRef<HTMLDivElement>  private univer?: Univer  ngAfterViewInit() {    const container = this.containerRef.nativeElement    const univer = new Univer({      locale: LocaleType.JA_JP,      locales: {        [LocaleType.JA_JP]: mergeLocales(          DesignjaJP,          UIjaJP,          DocsUIjaJP,          SlidesjaJP,          SlidesUIjaJP,        ),      },    })    univer.registerPlugin(UniverLicensePlugin, {      license: 'your license.txt',    })    univer.registerPlugin(UniverRenderEnginePlugin)    univer.registerPlugin(UniverUIPlugin, {      container,    })    univer.registerPlugin(UniverDocsPlugin)    univer.registerPlugin(UniverDocsUIPlugin)    univer.registerPlugin(UniverDrawingPlugin)    univer.registerPlugin(UniverSlidesPlugin)    univer.registerPlugin(UniverSlidesUIPlugin)    univer.createUnit(UniverInstanceType.UNIVER_SLIDE, {})    this.univer = univer  }  ngOnDestroy() {    this.univer?.dispose()  }}

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

© 2026 DreamNum Co., Ltd.