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.