Skip to content

DOCXKIT_STYLE_CIRCULAR_EXTENDS: 樣式繼承形成循環 ​

extends 鏈引用了正在解析的樣式類別。

修復步驟 ​

  1. 沿錯誤訊息中的繼承鏈檢查引用。
  2. 刪除閉合循環的引用,共用父樣式仍可使用。

問題範例 ​

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

const styles = defineStyles({
  body: { extends: 'title' }, title: { extends: 'body' },
})
await createDocx({ styles }).p('Hello', { className: 'body' }).toBlob()

修復範例 ​

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

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

常見原因 ​

  • 樣式繼承自身,或多個樣式類別互相繼承形成閉環。

診斷欄位 ​

訊息範例 ​

text
Circular extends detected for style class "body". Chain: body → title → body

原始碼與相關指南 ​

Released under the MIT License.