{"id":27558,"date":"2024-11-24T09:46:44","date_gmt":"2024-11-24T01:46:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27558\/"},"modified":"2024-11-24T09:46:44","modified_gmt":"2024-11-24T01:46:44","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-html-%e4%b8%ad%e5%ae%9e%e7%8e%b0%e7%ba%af%e6%95%b0%e5%ad%97%e8%b7%a8%e8%a1%8c%e5%b9%b6%e5%8e%bb%e6%8e%89%e5%b0%be%e6%95%b0-0-%e7%9a%84%e6%95%b0%e5%ad%97%e8%be%93%e5%85%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27558\/","title":{"rendered":"\u5982\u4f55\u5728 HTML \u4e2d\u5b9e\u73b0\u7eaf\u6570\u5b57\u8de8\u884c\u5e76\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173129022395881.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 HTML \u4e2d\u5b9e\u73b0\u7eaf\u6570\u5b57\u8de8\u884c\u5e76\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5728 HTML \u4e2d\u5b9e\u73b0\u7eaf\u6570\u5b57\u8de8\u884c\u5e76\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0 html \u4e2d\u7eaf\u6570\u5b57\u8de8\u884c\u5e76\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846<\/strong><\/p>\n<p>\u8981\u5728 HTML \u4e2d\u5b9e\u73b0\u5141\u8bb8\u8f93\u5165\u7eaf\u6570\u5b57\u3001\u8fc7\u957f\u81ea\u52a8\u6362\u884c\u4e14\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\uff0c\u9700\u8981\u4f7f\u7528 textarea \u5143\u7d20\u5e76\u5728\u8f93\u5165\u65f6\u8fdb\u884c\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li> <strong>\u9650\u5236\u53ea\u80fd\u8f93\u5165\u6570\u5b57\uff1a<\/strong>\u4f7f\u7528 keyup \u4e8b\u4ef6\u76d1\u542c\u8f93\u5165\u6846\u7684\u8f93\u5165\uff0c\u5e76\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fc7\u6ee4\u6389\u975e\u6570\u5b57\u5b57\u7b26\u3002<\/li>\n<li> <strong>\u53bb\u9664\u5c3e\u6570 0\uff1a<\/strong>\u518d\u6b21\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u53bb\u6389\u6570\u5b57\u672b\u5c3e\u7684 0\uff0c\u9664\u975e\u5c0f\u6570\u70b9\u540e\u6709\u975e 0 \u6570\u5b57\u3002<\/li>\n<li> <strong>\u81ea\u52a8\u6362\u884c\uff1a<\/strong>\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u6570\u5b57\u6bcf 6 \u4e2a\u5b57\u7b26\u4e3a\u4e00\u7ec4\uff0c\u5e76\u5728\u6bcf\u7ec4\u540e\u6dfb\u52a0\u6362\u884c\u7b26\u3002<\/li>\n<li> <strong>\u663e\u793a\u5904\u7406\u540e\u7684\u6570\u5b57\uff1a<\/strong>\u5c06\u5904\u7406\u540e\u7684\u6570\u5b57\u663e\u793a\u5728 textarea \u4e2d\uff0c\u540c\u65f6\u4fdd\u7559\u539f\u59cb\u8f93\u5165\u503c\u4ee5\u63d0\u4ea4\u3002<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>&lt;script setup&gt;\nimport { ref } from \"vue\";\n\nconst textarea_number_data = ref();\nconst textarea_number = ref();\nconst keyupNumber = () =&gt; {\n    textarea_number_data.value = textarea_number.value\n        .replace(\/[^d.]\/g, \"\")\n        .replace(\/.(?=.*.)\/g, \"\");\n    textarea_number.value = textarea_number_data.value.match(\/.{1,6}\/g).join(\"\n\");\n};\n&lt;\/script&gt;\n\n&lt;template&gt;\n&lt;textarea v-model=\"textarea_number\" @keyup=\"keyupNumber()\"&gt;&lt;\/textarea&gt;\n&lt;\/template&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f7f\u7528\u6b64\u4ee3\u7801\uff0c\u5373\u53ef\u5728 HTML \u4e2d\u521b\u5efa\u4e00\u4e2a\u7eaf\u6570\u5b57\u4e14\u53ef\u4ee5\u81ea\u52a8\u6362\u884c\u3001\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\u3002\u6570\u636e\u5728\u63d0\u4ea4\u65f6\u4ecd\u7136\u53ef\u4ee5\u83b7\u53d6\u5230\u539f\u59cb\u8f93\u5165\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728 HTML \u4e2d\u5b9e\u73b0\u7eaf\u6570\u5b57\u8de8\u884c\u5e76\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\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 html \u4e2d\u7eaf\u6570\u5b57\u8de8\u884c\u5e76\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846 \u8981\u5728 HTML \u4e2d\u5b9e\u73b0\u5141\u8bb8\u8f93\u5165\u7eaf\u6570\u5b57\u3001\u8fc7\u957f\u81ea\u52a8\u6362\u884c\u4e14\u53bb\u6389\u5c3e\u6570 0 \u7684\u6570\u5b57\u8f93\u5165\u6846\uff0c\u9700\u8981\u4f7f\u7528 textarea \u5143\u7d20\u5e76\u5728\u8f93\u5165\u65f6\u8fdb\u884c\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b65\u9aa4\uff1a \u9650\u5236\u53ea\u80fd\u8f93\u5165\u6570\u5b57\uff1a\u4f7f\u7528 keyup \u4e8b\u4ef6\u76d1\u542c\u8f93\u5165\u6846\u7684\u8f93\u5165\uff0c\u5e76\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fc7\u6ee4\u6389\u975e\u6570\u5b57\u5b57\u7b26\u3002 \u53bb\u9664\u5c3e\u6570 0\uff1a\u518d\u6b21\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u53bb\u6389\u6570\u5b57\u672b\u5c3e\u7684 0\uff0c\u9664\u975e\u5c0f\u6570\u70b9\u540e\u6709\u975e 0 \u6570\u5b57\u3002 \u81ea\u52a8\u6362\u884c\uff1a\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u6570\u5b57\u6bcf 6 \u4e2a\u5b57\u7b26\u4e3a\u4e00\u7ec4\uff0c\u5e76\u5728\u6bcf\u7ec4\u540e\u6dfb\u52a0\u6362\u884c\u7b26\u3002 \u663e\u793a\u5904\u7406\u540e\u7684\u6570\u5b57\uff1a\u5c06\u5904\u7406\u540e\u7684\u6570\u5b57\u663e\u793a\u5728 textarea \u4e2d\uff0c\u540c\u65f6\u4fdd\u7559\u539f\u59cb\u8f93\u5165\u503c\u4ee5\u63d0\u4ea4\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a &lt;script setup&gt; import { ref } from &#8220;vue&#8221;; const textarea_number_data = ref(); const textarea_number = ref(); const keyupNumber = () =&gt; { textarea_number_data.value = textarea_number.value .replace(\/[^d.]\/g, &#8220;&#8221;) .replace(\/.(?=.*.)\/g, [&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-27558","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27558","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=27558"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27558\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}