Browse Source

image为空时不渲染comment-item-image

narro 6 years ago
parent
commit
976305af5a

+ 6
- 2
lib/components/ContentItem/index.js View File

143
         newContent = newContent.join("");
143
         newContent = newContent.join("");
144
       }
144
       }
145
 
145
 
146
+      var imageList = images.split(",");
147
+
146
       return _react2.default.createElement(
148
       return _react2.default.createElement(
147
         "div",
149
         "div",
148
         { className: "comment-item-box" },
150
         { className: "comment-item-box" },
181
               __html: (0, _helper.renderContent)(this.renderTextWithReply(newContent, content))
183
               __html: (0, _helper.renderContent)(this.renderTextWithReply(newContent, content))
182
             }
184
             }
183
           }),
185
           }),
184
-          _react2.default.createElement(
186
+
187
+          // image为空时不渲染comment-item-image
188
+          imageList.length > 0 && imageList[0] !== '' && _react2.default.createElement(
185
             "div",
189
             "div",
186
             { className: "comment-item-image" },
190
             { className: "comment-item-image" },
187
-            images.split(",").map(function (item, index) {
191
+            imageList.map(function (item, index) {
188
               return _react2.default.createElement("img", {
192
               return _react2.default.createElement("img", {
189
                 key: index,
193
                 key: index,
190
                 src: item,
194
                 src: item,

+ 1
- 1
lib/components/ContentItem/index.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
lib/components/Editor/index.js.map
File diff suppressed because it is too large
View File


+ 18
- 12
src/components/ContentItem/index.js View File

70
       newContent = newContent.join("");
70
       newContent = newContent.join("");
71
     }
71
     }
72
 
72
 
73
+    const imageList = images.split(",");
74
+
73
     return (
75
     return (
74
       <div className="comment-item-box">
76
       <div className="comment-item-box">
75
         <div className="comment-item-left">
77
         <div className="comment-item-left">
100
               )
102
               )
101
             }}
103
             }}
102
           />
104
           />
103
-          <div className="comment-item-image">
104
-            {images.split(",").map((item, index) => {
105
-              return (
106
-                <img
107
-                  key={index}
108
-                  src={item}
109
-                  alt={item}
110
-                  style={{ maxWidth: "100%" }}
111
-                />
112
-              );
113
-            })}
114
-          </div>
105
+          {// image为空时不渲染comment-item-image
106
+          imageList.length > 0 &&
107
+            imageList[0] !== "" && (
108
+              <div className="comment-item-image">
109
+                {imageList.map((item, index) => {
110
+                  return (
111
+                    <img
112
+                      key={index}
113
+                      src={item}
114
+                      alt={item}
115
+                      style={{ maxWidth: "100%" }}
116
+                    />
117
+                  );
118
+                })}
119
+              </div>
120
+            )}
115
           <div className="comment-item-bottom">
121
           <div className="comment-item-bottom">
116
             {content.reply_count ? (
122
             {content.reply_count ? (
117
               <div>
123
               <div>