Skip to content

DOCXKIT_STYLE_UNKNOWN_CLASS: 樣式類別不存在 ​

className 或 extends 引用的名稱與樣式表鍵不符。

修復步驟 ​

  1. 核對引用名稱和樣式表鍵,注意拼寫。
  2. 呼叫 defineStyles 前補齊父樣式定義。

問題範例 ​

ts
import { defineStyles } from 'docx-kit'

defineStyles({ body: { extends: 'missing' } })

修復範例 ​

ts
import { createDocx, defineStyles } from 'docx-kit'

const styles = defineStyles({ body: { fontSize: 12 } })
const blob = await createDocx({ styles })
  .p('Hello', { className: 'body' })
  .toBlob()

常見原因 ​

  • 名稱拼寫錯誤、父樣式缺失,或使用了錯誤的樣式表。

診斷欄位 ​

訊息範例 ​

text
Style class not found: "boddy"

原始碼與相關指南 ​

Released under the MIT License.