DOCXKIT_PLUGIN_RENDER_FAILED: 插件渲染失败
插件 render 方法抛错,或 PDK 渲染断言拒绝其输出。
修复步骤
- 在本地检查原始 cause,并核对插件选项。
- render 返回受支持的 docx 元素。
- 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 输出类型不符。
诊断字段
code:PLUGIN_RENDER_FAILEDdiagnosticCode:DOCXKIT_PLUGIN_RENDER_FAILEDname:DocxKitErrordocs: https://docx-kit.ntnyq.dev/errors/docxkit_plugin_render_failed/
消息示例
text
Plugin render failed: example