Commit cccc5fe0694b164b383e6a78fda0295a3515b874
1 parent
09f87ae4
fix:增加异常机制
Showing
1 changed file
with
13 additions
and
8 deletions
src/utils/index.js
... | ... | @@ -614,13 +614,18 @@ export function getBlob(url) { |
614 | 614 | }); |
615 | 615 | } |
616 | 616 | export function fetchHTML(url) { |
617 | - var xhr = new XMLHttpRequest(); | |
618 | - xhr.open("GET", url, false); | |
619 | - xhr.send(); | |
620 | - if (xhr.status === 200) { | |
621 | - return xhr.responseText; | |
622 | - } else { | |
623 | - return null; | |
617 | + try { | |
618 | + var xhr = new XMLHttpRequest(); | |
619 | + xhr.open("GET", url, false); | |
620 | + xhr.send(); | |
621 | + if (xhr.status === 200) { | |
622 | + return xhr.responseText; | |
623 | + } else { | |
624 | + return ""; | |
625 | + } | |
626 | + } | |
627 | + catch (e) { | |
628 | + return ""; | |
624 | 629 | } |
625 | 630 | } |
626 | 631 | /** |
... | ... | @@ -989,7 +994,7 @@ export function paperPrint(paper) { |
989 | 994 | } |
990 | 995 | // size: A4 portrait; |
991 | 996 | // size: A3 landscape; |
992 | - | |
997 | + | |
993 | 998 | const style = printWin.document.createElement('style'); |
994 | 999 | style.innerHTML = ` |
995 | 1000 | @media print | ... | ... |