From 5459f7634905cdae11b03200659ddb4c79562be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= Date: Thu, 10 Mar 2022 15:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BDword?= =?UTF-8?q?=E4=B8=AD=E4=B8=8D=E5=B8=A6=E5=9B=BE=E7=89=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/components/ExportWord.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/military/components/ExportWord.js b/src/military/components/ExportWord.js index 59a9511f..10479c4b 100644 --- a/src/military/components/ExportWord.js +++ b/src/military/components/ExportWord.js @@ -38,7 +38,19 @@ class ExportWord extends Component { body: '_body_', }; - const activeDoc = document.getElementById(wordId).cloneNode(true); // 获取 dom 节点 + const activeDoc = document.getElementById(wordId); // 获取 dom 节点 + + if(activeDoc.querySelector(".markdown-body")){ + let imgNode =activeDoc.querySelectorAll('.markdown-body img'); + if(imgNode.length){ + for(const item of imgNode){ + let itemSrc=item.getAttribute('src'); + if(itemSrc.indexOf('http')===-1){ + item.setAttribute('src',location.origin+itemSrc); + } + } + } + } // 默认样式 const defaultStyle = '.text-div{ text-decoration: underline; margin-right: 15px; } .textarea-div{ text-decoration: underline; } table td,table th{padding: 6px 13px;border: 1px solid #ddd;} table{border-collapse: collapse;}';