{"id":3698,"date":"2024-11-10T09:16:22","date_gmt":"2024-11-10T01:16:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3698\/"},"modified":"2024-11-10T09:16:22","modified_gmt":"2024-11-10T01:16:22","slug":"%e5%a6%82%e4%bd%95%e7%a1%ae%e4%bf%9d%e7%94%a8%e6%88%b7%e6%8c%89%e9%a1%ba%e5%ba%8f%e5%a1%ab%e5%86%99%e8%a1%a8%e5%8d%95%e4%b8%94%e6%af%8f%e4%b8%aa%e8%be%93%e5%85%a5%e6%a1%86%e9%83%bd%e4%b8%8d%e4%b8%ba","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3698\/","title":{"rendered":"\u5982\u4f55\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8868\u5355\u4e14\u6bcf\u4e2a\u8f93\u5165\u6846\u90fd\u4e0d\u4e3a\u7a7a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173112105225941.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8868\u5355\u4e14\u6bcf\u4e2a\u8f93\u5165\u6846\u90fd\u4e0d\u4e3a\u7a7a\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8868\u5355\u4e14\u6bcf\u4e2a\u8f93\u5165\u6846\u90fd\u4e0d\u4e3a\u7a7a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6821\u9a8c\u8f93\u5165\u6846\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u4e14\u5fc5\u987b\u6309\u987a\u5e8f\u586b\u5199\u7684\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u5728\u5f00\u53d1\u524d\u7aef\u9875\u9762\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u6821\u9a8c\u8868\u5355\u8f93\u5165\u6846\uff0c\u786e\u4fdd\u5b83\u4eec\u4e0d\u4e3a\u7a7a\u4e14\u6309\u6b63\u786e\u7684\u987a\u5e8f\u586b\u5199\u3002\u4f8b\u5982\uff0c\u5728\u4e00\u7ec4\u8f93\u5165\u6846\u4e2d\uff0c\u8981\u6c42\u7528\u6237\u4ece\u7b2c\u4e00\u4e2a\u8f93\u5165\u6846\u5f00\u59cb\u9010\u4e2a\u586b\u5199\uff0c\u4e14\u4e0d\u80fd\u4e3a\u7a7a\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<ul>\n<li>\u4e3a\u6bcf\u4e2a\u8f93\u5165\u6846\u6dfb\u52a0\u4e00\u4e2a\u552f\u4e00\u7684 name \u5c5e\u6027\u3002<\/li>\n<li>\u6dfb\u52a0\u4e00\u4e2a\u4e8b\u4ef6\u4fa6\u542c\u5668\uff0c\u5728\u7528\u6237\u5728\u6bcf\u4e2a\u8f93\u5165\u6846\u8f93\u5165\u5185\u5bb9\u4e4b\u524d\u89e6\u53d1\u3002<\/li>\n<li>\u5728\u4e8b\u4ef6\u4fa6\u542c\u5668\u4e2d\uff0c\u5224\u65ad\u5f53\u524d\u8f93\u5165\u6846\u7684\u524d\u4e00\u4e2a\u8f93\u5165\u6846\u662f\u5426\u6709\u503c\u3002\u5982\u679c\u6ca1\u6709\u503c\uff0c\u5219\u63d0\u793a\u7528\u6237\u5148\u586b\u5199\u524d\u4e00\u4e2a\u8f93\u5165\u6846\u3002<\/li>\n<\/ul>\n<p><strong>\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n<pre>&lt;input type=\"text\" name=\"input1\" \/&gt;\n&lt;input type=\"text\" name=\"input2\" \/&gt;\n\n&lt;script&gt;\n  \/\/ \u83b7\u53d6\u8f93\u5165\u6846\n  const input1 = document.querySelector('input[name=\"input1\"]');\n  const input2 = document.querySelector('input[name=\"input2\"]');\n\n  \/\/ \u6dfb\u52a0\u4e8b\u4ef6\u4fa6\u542c\u5668\n  input2.addEventListener('focus', function() {\n    \/\/ \u68c0\u67e5 input1 \u662f\u5426\u6709\u503c\n    if (!input1.value) {\n      \/\/ \u63d0\u793a\u7528\u6237\u5148\u586b\u5199 input1\n      alert('\u8bf7\u5148\u586b\u5199\u8f93\u5165\u6846 1');\n      \/\/ \u5c06\u7126\u70b9\u8bbe\u7f6e\u56de input1\n      input1.focus();\n    }\n  });\n&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8f93\u5165\u6846\uff0c\u5e76\u9632\u6b62\u7559\u4e0b\u7a7a\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8868\u5355\u4e14\u6bcf\u4e2a\u8f93\u5165\u6846\u90fd\u4e0d\u4e3a\u7a7a\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>\u6821\u9a8c\u8f93\u5165\u6846\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u4e14\u5fc5\u987b\u6309\u987a\u5e8f\u586b\u5199\u7684\u89e3\u51b3\u65b9\u6848 \u5728\u5f00\u53d1\u524d\u7aef\u9875\u9762\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u6821\u9a8c\u8868\u5355\u8f93\u5165\u6846\uff0c\u786e\u4fdd\u5b83\u4eec\u4e0d\u4e3a\u7a7a\u4e14\u6309\u6b63\u786e\u7684\u987a\u5e8f\u586b\u5199\u3002\u4f8b\u5982\uff0c\u5728\u4e00\u7ec4\u8f93\u5165\u6846\u4e2d\uff0c\u8981\u6c42\u7528\u6237\u4ece\u7b2c\u4e00\u4e2a\u8f93\u5165\u6846\u5f00\u59cb\u9010\u4e2a\u586b\u5199\uff0c\u4e14\u4e0d\u80fd\u4e3a\u7a7a\u3002 \u89e3\u51b3\u65b9\u6848 \u4e3a\u6bcf\u4e2a\u8f93\u5165\u6846\u6dfb\u52a0\u4e00\u4e2a\u552f\u4e00\u7684 name \u5c5e\u6027\u3002 \u6dfb\u52a0\u4e00\u4e2a\u4e8b\u4ef6\u4fa6\u542c\u5668\uff0c\u5728\u7528\u6237\u5728\u6bcf\u4e2a\u8f93\u5165\u6846\u8f93\u5165\u5185\u5bb9\u4e4b\u524d\u89e6\u53d1\u3002 \u5728\u4e8b\u4ef6\u4fa6\u542c\u5668\u4e2d\uff0c\u5224\u65ad\u5f53\u524d\u8f93\u5165\u6846\u7684\u524d\u4e00\u4e2a\u8f93\u5165\u6846\u662f\u5426\u6709\u503c\u3002\u5982\u679c\u6ca1\u6709\u503c\uff0c\u5219\u63d0\u793a\u7528\u6237\u5148\u586b\u5199\u524d\u4e00\u4e2a\u8f93\u5165\u6846\u3002 \u4ee3\u7801\u793a\u4f8b &lt;input type=&#8221;text&#8221; name=&#8221;input1&#8243; \/&gt; &lt;input type=&#8221;text&#8221; name=&#8221;input2&#8243; \/&gt; &lt;script&gt; \/\/ \u83b7\u53d6\u8f93\u5165\u6846 const input1 = document.querySelector(&#8216;input[name=&#8221;input1&#8243;]&#8217;); const input2 = document.querySelector(&#8216;input[name=&#8221;input2&#8243;]&#8217;); \/\/ \u6dfb\u52a0\u4e8b\u4ef6\u4fa6\u542c\u5668 input2.addEventListener(&#8216;focus&#8217;, function() { \/\/ \u68c0\u67e5 input1 \u662f\u5426\u6709\u503c if (!input1.value) { \/\/ \u63d0\u793a\u7528\u6237\u5148\u586b\u5199 input1 alert(&#8216;\u8bf7\u5148\u586b\u5199\u8f93\u5165\u6846 1&#8217;); \/\/ \u5c06\u7126\u70b9\u8bbe\u7f6e\u56de input1 input1.focus(); } }); &lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8f93\u5165\u6846\uff0c\u5e76\u9632\u6b62\u7559\u4e0b\u7a7a\u503c\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u786e\u4fdd\u7528\u6237\u6309\u987a\u5e8f\u586b\u5199\u8868\u5355\u4e14\u6bcf\u4e2a\u8f93\u5165\u6846\u90fd\u4e0d\u4e3a\u7a7a\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3698","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3698","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=3698"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3698\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}