Selaa lähdekoodia

html.trim() = '' 显示placeholder

visuddhinanda 2 vuotta sitten
vanhempi
sitoutus
41dcdda1df
1 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 7 2
      dashboard/src/components/template/MdView.tsx

+ 7 - 2
dashboard/src/components/template/MdView.tsx

@@ -1,6 +1,6 @@
 import { Typography } from "antd";
 import { TCodeConvertor, XmlToReact } from "./utilities";
-const { Paragraph } = Typography;
+const { Paragraph, Text } = Typography;
 
 interface IWidget {
   html?: string;
@@ -18,7 +18,12 @@ const Widget = ({
   convertor,
   style,
 }: IWidget) => {
-  const jsx = html ? XmlToReact(html, wordWidget, convertor) : placeholder;
+  const jsx =
+    html && html.trim() !== "" ? (
+      XmlToReact(html, wordWidget, convertor)
+    ) : (
+      <Text type="secondary">{placeholder}</Text>
+    );
   return (
     <Paragraph style={style} className={className}>
       {jsx}