{"id":26025,"date":"2024-11-24T11:44:30","date_gmt":"2024-11-24T03:44:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26025\/"},"modified":"2024-11-24T11:44:30","modified_gmt":"2024-11-24T03:44:30","slug":"element-ui-button-%e7%82%b9%e5%87%bb%e5%90%8e%e8%83%8c%e6%99%af%e8%89%b2%e5%a6%82%e4%bd%95%e6%b6%88%e5%a4%b1%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26025\/","title":{"rendered":"Element-UI Button \u70b9\u51fb\u540e\u80cc\u666f\u8272\u5982\u4f55\u6d88\u5931\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173077686368249.jpg\" class=\"aligncenter\" title=\"Element-UI Button \u70b9\u51fb\u540e\u80cc\u666f\u8272\u5982\u4f55\u6d88\u5931\uff1f\u63d2\u56fe\" alt=\"Element-UI Button \u70b9\u51fb\u540e\u80cc\u666f\u8272\u5982\u4f55\u6d88\u5931\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>element-ui button \u70b9\u51fb\u80cc\u666f\u8272\u540e\u5982\u4f55\u9f20\u6807\u79fb\u5f00\u6d88\u5931<\/strong><\/p>\n<p>element-ui \u7684 button \u70b9\u51fb\u540e\u4f1a\u6709\u4e00\u4e2a\u80cc\u666f\u8272\uff0c\u4f46\u70b9\u51fb\u5176\u4ed6\u5730\u65b9\u540e\uff0c\u80cc\u666f\u8272\u4e0d\u4f1a\u6d88\u5931\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u5982\u4f55\u8ba9\u9f20\u6807\u79fb\u5f00\u540e\u80cc\u666f\u8272\u7acb\u5373\u6d88\u5931\u3002<\/p>\n<\/p>\n<p> \u7c7b\u4f3c\u8fd9\u6837:<\/p>\n<p>\u70b9\u51fb\u7a7a\u767d\u533a\u57df\u53d8\u4e3a\u767d\u8272<\/p>\n<\/p>\n<p>\u9020\u6210\u80cc\u666f\u8272\u65e0\u6cd5\u6d88\u5931\u7684\u539f\u56e0\u5728\u4e8e <\/p>\n<p>:focus \u7684\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" style=\"max-width:90%\" src=\"https:\/\/segmentfault.com\/img\/bvc9ucq\" class=\"aligncenter\" title=\"Element-UI Button \u70b9\u51fb\u540e\u80cc\u666f\u8272\u5982\u4f55\u6d88\u5931\uff1f\u63d2\u56fe1\" alt=\"Element-UI Button \u70b9\u51fb\u540e\u80cc\u666f\u8272\u5982\u4f55\u6d88\u5931\uff1f\u63d2\u56fe1\" \/><\/p>\n<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b javascript \u4ee3\u7801\u89e3\u51b3\u6b64\u95ee\u9898\uff1a<\/p>\n<pre>clickhandler(evt) {\n    let target = evt.target;\n    if(target.nodename == \"span\"){\n        target = evt.target.parentnode;\n    }\n    target.blur();\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6216\u8005\uff0c\u4fee\u6539  \u6837\u5f0f\uff1a<\/p>\n<pre>&lt;el-button class=\"buttondiv\" size=\"small\"&gt;\u67e5\u8be2&lt;\/el-button&gt;\n&lt;el-button class=\"buttondiv\" size=\"small\"&gt;\u91cd\u7f6e&lt;\/el-button&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>\/*\u9f20\u6807\u70b9\u51fb\u540e\u79fb\u5f00\uff0c\u6062\u590d\u672c\u8eab\u6837\u5f0f*\/\n.buttonDiv, .buttonDiv:focus:not(.buttonDiv:hover){ \n    margin-right: 12px;\n    border: 1px solid #2794f8;\n    border-radius: 2px;\n    box-shadow: 0 2px 4px 0 #f4f4f4;\n    color: #2794f8;\n    background: white;\n}\n\/*\u9f20\u6807\u60ac\u6d6e\uff0c\u6ca1\u6709\u6309\u4e0b\uff1b\u9f20\u6807\u6309\u4e0b\u540e\u62ac\u8d77\uff0c\u6ca1\u6709\u79fb\u5f00*\/\n.buttonDiv:focus, .buttonDiv:hover{\n    background: #eaf5ff;\n    border: 1px solid #2794f8 !important;\n    color: #2794f8;\n}\n\/*\u9f20\u6807\u6309\u4e0b\uff0c\u6ca1\u6709\u62ac\u8d77*\/\n.buttonDiv:active {\n    background: #2794f8;\n    color: white;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fElement-UI Button \u70b9\u51fb\u540e\u80cc\u666f\u8272\u5982\u4f55\u6d88\u5931\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>element-ui button \u70b9\u51fb\u80cc\u666f\u8272\u540e\u5982\u4f55\u9f20\u6807\u79fb\u5f00\u6d88\u5931 element-ui \u7684 button \u70b9\u51fb\u540e\u4f1a\u6709\u4e00\u4e2a\u80cc\u666f\u8272\uff0c\u4f46\u70b9\u51fb\u5176\u4ed6\u5730\u65b9\u540e\uff0c\u80cc\u666f\u8272\u4e0d\u4f1a\u6d88\u5931\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u5982\u4f55\u8ba9\u9f20\u6807\u79fb\u5f00\u540e\u80cc\u666f\u8272\u7acb\u5373\u6d88\u5931\u3002 \u7c7b\u4f3c\u8fd9\u6837: \u70b9\u51fb\u7a7a\u767d\u533a\u57df\u53d8\u4e3a\u767d\u8272 \u9020\u6210\u80cc\u666f\u8272\u65e0\u6cd5\u6d88\u5931\u7684\u539f\u56e0\u5728\u4e8e :focus \u7684\u4f7f\u7528\u3002 \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b javascript \u4ee3\u7801\u89e3\u51b3\u6b64\u95ee\u9898\uff1a clickhandler(evt) { let target = evt.target; if(target.nodename == &#8220;span&#8221;){ target = evt.target.parentnode; } target.blur(); } \u767b\u5f55\u540e\u590d\u5236 \u6216\u8005\uff0c\u4fee\u6539 \u6837\u5f0f\uff1a &lt;el-button class=&#8221;buttondiv&#8221; size=&#8221;small&#8221;&gt;\u67e5\u8be2&lt;\/el-button&gt; &lt;el-button class=&#8221;buttondiv&#8221; size=&#8221;small&#8221;&gt;\u91cd\u7f6e&lt;\/el-button&gt; \u767b\u5f55\u540e\u590d\u5236 \/*\u9f20\u6807\u70b9\u51fb\u540e\u79fb\u5f00\uff0c\u6062\u590d\u672c\u8eab\u6837\u5f0f*\/ .buttonDiv, .buttonDiv:focus:not(.buttonDiv:hover){ margin-right: 12px; border: 1px solid #2794f8; border-radius: 2px; box-shadow: 0 2px 4px [&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-26025","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26025","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=26025"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26025\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}