祖安之光
8 天以前 5df79be2b15c0c22e4c25f94b02464ad70d793c3
src/utils/exportWord.js
@@ -23,6 +23,22 @@
            }
            try {
                // 新版创建解析器的正确方式(无需 import AngularParser)
                const parser = (tag, _variable) => {
                    return {
                        get(scope) {
                            if (scope[tag] !== undefined) {
                                return scope[tag] || '';
                            }
                            // 处理特殊变量(如 $first)
                            if (tag.startsWith('$')) {
                                const varName = tag.slice(1);
                                return scope[varName] || '';
                            }
                            return '';
                        }
                    };
                };
                // 加载模板文件内容到 PizZip
                const zip = new PizZip(content);
                const doc = new Docxtemplater(zip, {
@@ -30,6 +46,10 @@
                    linebreaks: true,
                });
                // const parser = new AngularParser();
                // doc.setOptions({ parser });
                // 设置模板中的占位符数据
                doc.setData(data);