Feat:addContentToHeader方法支持返回空数据

This commit is contained in:
街角小林
2024-03-28 18:55:40 +08:00
parent f0c08c7953
commit 614aa1ec30
2 changed files with 4 additions and 2 deletions

View File

@@ -309,7 +309,7 @@ export const defaultOpt = {
*/
},
// 导出png、svg、pdf时在头部和尾部添加自定义内容
// 可传递一个函数,这个函数需要返回如下数据:
// 可传递一个函数,这个函数可以返回null代表不添加内容也可以返回如下数据:
/*
{
el,// 要追加的自定义DOM节点样式可内联

View File

@@ -1330,7 +1330,9 @@ export const handleGetSvgDataExtraContent = ({
let footerHeight = 0
const handle = (fn, callback) => {
if (typeof fn === 'function') {
const { el, cssText, height } = fn()
const res = fn()
if (!res) return
const { el, cssText, height } = res
if (el instanceof HTMLElement) {
el.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml')
const foreignObject = new ForeignObject()