Skip to content

DOCXKIT_PLUGIN_RENDER_FAILED: 外掛渲染失敗 ​

外掛 render 方法擲出錯誤,或 PDK 渲染斷言拒絕其輸出。

修復步驟 ​

  1. 在本機檢查原始 cause,並核對外掛選項。
  2. render 回傳受支援的 docx 元素。
  3. PDK 斷言失敗時核對預期元素類型和數量。

問題範例 ​

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

const plugin = definePlugin({
  name: 'example', render() { throw new Error('Resource unavailable') },
})
await createDocx().use(plugin).plugin('example', {}).toBlob()

修復範例 ​

ts
import { createDocx, definePlugin } from 'docx-kit'
import { Paragraph } from 'docx'

const plugin = definePlugin({
  name: 'example', render: () => new Paragraph('Hello'),
})
const blob = await createDocx().use(plugin).plugin('example', {}).toBlob()

常見原因 ​

  • 渲染器例外、選項無效,或 PDK 輸出類型不符。

診斷欄位 ​

訊息範例 ​

text
Plugin render failed: example

原始碼與相關指南 ​

Released under the MIT License.