{"id":28221,"date":"2024-11-24T08:26:32","date_gmt":"2024-11-24T00:26:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28221\/"},"modified":"2024-11-24T08:26:32","modified_gmt":"2024-11-24T00:26:32","slug":"%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e8%b6%85%e5%87%ba-div-%e7%95%8c%e9%9d%a2%e5%90%8e%e7%9a%84%e6%bb%91%e6%9d%a1%e5%b1%95%e7%a4%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28221\/","title":{"rendered":"\u5982\u4f55\u5b9e\u73b0\u8d85\u51fa div \u754c\u9762\u540e\u7684\u6ed1\u6761\u5c55\u793a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173146285780245.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u8d85\u51fa div \u754c\u9762\u540e\u7684\u6ed1\u6761\u5c55\u793a\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5b9e\u73b0\u8d85\u51fa div \u754c\u9762\u540e\u7684\u6ed1\u6761\u5c55\u793a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0\u8d85\u51fa div \u754c\u9762\u540e\u7684\u6ed1\u6761\u5c55\u793a<\/strong><\/p>\n<pre>export type ItemType = {\n    type: \"property\" | \"method\",\n    value: string,\n    selected?: boolean    \n}\n\nexport type SubContainerProps = {\n    height?: number,\n    title: string,\n    data: ItemType[], \/\/ \u8fd9\u4e2a\u662fitems\n}\n\nexport default function subContainer (props: SubContainerProps){ \n\n   \n\n    return (\n        &lt;div style={{borderRadius: '8px',  border: '2px dashed #333', height: props.height, overflow: 'auto'}}&gt;\n            &lt;div style={{textAlign: 'left'}}&gt;\n                &lt;label&gt;{props.title}&lt;\/label&gt;\n            &lt;\/div&gt;\n            &lt;div&gt;\n                {props.data.map((item, index) =&gt; (\n                    &lt;div \n                        key={`${index}-${item.type}-${item.value} `} \n                        style={{ \n                            float: 'left', \n                            display: 'inline-block', \n                            borderRadius: '6px', \n                            border: '2px solid #000', \n                            margin: '8px', \n                            padding:'4px',\n                            backgroundColor: item.selected ? '#39fe40': '' \n                        }}\n                        \n                    &gt;{item.value}&lt;\/div&gt;\n                ))}\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n    )\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5b9e\u73b0\u8d85\u51fa div \u754c\u9762\u540e\u7684\u6ed1\u6761\u5c55\u793a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5b9e\u73b0\u8d85\u51fa div \u754c\u9762\u540e\u7684\u6ed1\u6761\u5c55\u793a export type ItemType = { type: &#8220;property&#8221; | &#8220;method&#8221;, value: string, selected?: boolean } export type SubContainerProps = { height?: number, title: string, data: ItemType[], \/\/ \u8fd9\u4e2a\u662fitems } export default function subContainer (props: SubContainerProps){ return ( &lt;div style={{borderRadius: &#8216;8px&#8217;, border: &#8216;2px dashed #333&#8217;, height: props.height, overflow: &#8216;auto&#8217;}}&gt; &lt;div style={{textAlign: &#8216;left&#8217;}}&gt; &lt;label&gt;{props.title}&lt;\/label&gt; &lt;\/div&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-28221","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28221"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28221\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}