Browse Source

[issues/I5BFJT]online表单开发-点击【配置地址】报错-Uncaught ReferenceError: React is…

zhangdaiscott 2 years ago
parent
commit
38db7196c7
1 changed files with 20 additions and 11 deletions
  1. 20 11
      src/hooks/web/useMessage.tsx

+ 20 - 11
src/hooks/web/useMessage.tsx

@@ -35,21 +35,30 @@ interface ConfirmOptions {
 }
 
 function getIcon(iconType: string) {
-  if (iconType === 'warning') {
-    return <InfoCircleFilled class="modal-icon-warning" />;
-  } else if (iconType === 'success') {
-    return <CheckCircleFilled class="modal-icon-success" />;
-  } else if (iconType === 'info') {
-    return <InfoCircleFilled class="modal-icon-info" />;
-  } else {
-    return <CloseCircleFilled class="modal-icon-error" />;
+  try {
+    if (iconType === 'warning') {
+      return <InfoCircleFilled class="modal-icon-warning" />;
+    } else if (iconType === 'success') {
+      return <CheckCircleFilled class="modal-icon-success" />;
+    } else if (iconType === 'info') {
+      return <InfoCircleFilled class="modal-icon-info" />;
+    } else {
+      return <CloseCircleFilled class="modal-icon-error" />;
+    }
+  } catch(e) {
+    console.log(e);
   }
 }
 
 function renderContent({ content }: Pick<ModalOptionsEx, 'content'>) {
-  if (isString(content)) {
-    return <div innerHTML={`<div>${content as string}</div>`}></div>;
-  } else {
+  try {
+    if (isString(content)) {
+      return <div innerHTML={`<div>${content as string}</div>`}></div>;
+    } else {
+      return content;
+    }
+  } catch(e) {
+    console.log(e);
     return content;
   }
 }