Explorar el Código

html.trim() = '' 显示placeholder

visuddhinanda hace 2 años
padre
commit
41dcdda1df
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  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 { Typography } from "antd";
 import { TCodeConvertor, XmlToReact } from "./utilities";
 import { TCodeConvertor, XmlToReact } from "./utilities";
-const { Paragraph } = Typography;
+const { Paragraph, Text } = Typography;
 
 
 interface IWidget {
 interface IWidget {
   html?: string;
   html?: string;
@@ -18,7 +18,12 @@ const Widget = ({
   convertor,
   convertor,
   style,
   style,
 }: IWidget) => {
 }: IWidget) => {
-  const jsx = html ? XmlToReact(html, wordWidget, convertor) : placeholder;
+  const jsx =
+    html && html.trim() !== "" ? (
+      XmlToReact(html, wordWidget, convertor)
+    ) : (
+      <Text type="secondary">{placeholder}</Text>
+    );
   return (
   return (
     <Paragraph style={style} className={className}>
     <Paragraph style={style} className={className}>
       {jsx}
       {jsx}