{"id":25976,"date":"2024-11-24T11:50:48","date_gmt":"2024-11-24T03:50:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25976\/"},"modified":"2024-11-24T11:50:48","modified_gmt":"2024-11-24T03:50:48","slug":"%e9%bc%a0%e6%a0%87%e7%a7%bb%e5%bc%80-element-ui-%e6%8c%89%e9%92%ae%e5%90%8e%e5%a6%82%e4%bd%95%e6%b8%85%e9%99%a4%e8%83%8c%e6%99%af%e8%89%b2%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25976\/","title":{"rendered":"\u9f20\u6807\u79fb\u5f00 element-ui \u6309\u94ae\u540e\u5982\u4f55\u6e05\u9664\u80cc\u666f\u8272\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173076877175210.jpg\" class=\"aligncenter\" title=\"\u9f20\u6807\u79fb\u5f00 element-ui \u6309\u94ae\u540e\u5982\u4f55\u6e05\u9664\u80cc\u666f\u8272\uff1f\u63d2\u56fe\" alt=\"\u9f20\u6807\u79fb\u5f00 element-ui \u6309\u94ae\u540e\u5982\u4f55\u6e05\u9664\u80cc\u666f\u8272\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u9f20\u6807\u79fb\u5f00\u65f6\u5982\u4f55\u6e05\u9664 element-ui \u6309\u94ae\u80cc\u666f\u8272\uff1f<\/strong><\/p>\n<p>\u7c7b\u4f3c\u4e8e\u70b9\u51fb\u7a7a\u767d\u533a\u57df\u53d8\u4e3a\u767d\u8272\uff0celement-ui \u6309\u94ae\u5728\u70b9\u51fb\u540e\u4f1a\u663e\u793a\u80cc\u666f\u8272\u3002\u7136\u800c\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5f53\u9f20\u6807\u79fb\u5f00\u65f6\u80cc\u666f\u8272\u4e0d\u4f1a\u6d88\u5931\u3002<\/p>\n<p>\u95ee\u9898\u539f\u56e0\uff1a<\/p>\n<p>\u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u662f\u56e0\u4e3a\u6309\u94ae\u4f7f\u7528\u4e86 :focus \u6837\u5f0f\u3002\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c\u8be5\u6837\u5f0f\u4f1a\u88ab\u6fc0\u6d3b\uff0c\u4ece\u800c\u5bfc\u81f4\u80cc\u666f\u8272\u663e\u793a\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 blur() \u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 blur() \u65b9\u6cd5\uff0c\u53ef\u4ee5\u5f3a\u5236\u6309\u94ae\u5931\u53bb\u7126\u70b9\uff0c\u4ece\u800c\u6e05\u9664\u80cc\u666f\u8272\u3002<\/p>\n<pre>clickhandler(evt) {\n    let target = evt.target;\n    if(target.nodename == \"span\"){\n        target = evt.target.parentnode;\n    }\n    target.blur(); \/\/ \u5f3a\u5236\u6309\u94ae\u5931\u53bb\u7126\u70b9\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u91cd\u5199  \u6837\u5f0f\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 css \u6837\u5f0f\u6765\u91cd\u5199\u6309\u94ae\u7684\u9ed8\u8ba4\u884c\u4e3a\u3002\u5c06\u4ee5\u4e0b\u6837\u5f0f\u6dfb\u52a0\u5230\u4f60\u7684\u9879\u76ee\u4e2d\uff1a<\/p>\n<pre>.buttonDiv, .buttonDiv:focus:not(.buttonDiv:hover){ \n    \/* \u9f20\u6807\u70b9\u51fb\u540e\u79fb\u5f00\uff0c\u6062\u590d\u672c\u8eab\u6837\u5f0f *\/\n    background: white;\n}\n.buttonDiv:focus, .buttonDiv:hover{\n    \/* \u9f20\u6807\u60ac\u6d6e\uff0c\u6ca1\u6709\u6309\u4e0b\uff1b\u9f20\u6807\u6309\u4e0b\u540e\u62ac\u8d77\uff0c\u6ca1\u6709\u79fb\u5f00 *\/\n    background: #eaf5ff;\n}\n.buttonDiv:active {\n    \/* \u9f20\u6807\u6309\u4e0b\uff0c\u6ca1\u6709\u62ac\u8d77 *\/\n    background: #2794f8;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9f20\u6807\u79fb\u5f00 element-ui \u6309\u94ae\u540e\u5982\u4f55\u6e05\u9664\u80cc\u666f\u8272\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>\u9f20\u6807\u79fb\u5f00\u65f6\u5982\u4f55\u6e05\u9664 element-ui \u6309\u94ae\u80cc\u666f\u8272\uff1f \u7c7b\u4f3c\u4e8e\u70b9\u51fb\u7a7a\u767d\u533a\u57df\u53d8\u4e3a\u767d\u8272\uff0celement-ui \u6309\u94ae\u5728\u70b9\u51fb\u540e\u4f1a\u663e\u793a\u80cc\u666f\u8272\u3002\u7136\u800c\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5f53\u9f20\u6807\u79fb\u5f00\u65f6\u80cc\u666f\u8272\u4e0d\u4f1a\u6d88\u5931\u3002 \u95ee\u9898\u539f\u56e0\uff1a \u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u662f\u56e0\u4e3a\u6309\u94ae\u4f7f\u7528\u4e86 :focus \u6837\u5f0f\u3002\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c\u8be5\u6837\u5f0f\u4f1a\u88ab\u6fc0\u6d3b\uff0c\u4ece\u800c\u5bfc\u81f4\u80cc\u666f\u8272\u663e\u793a\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 blur() \u65b9\u6cd5\uff1a \u901a\u8fc7\u4f7f\u7528 blur() \u65b9\u6cd5\uff0c\u53ef\u4ee5\u5f3a\u5236\u6309\u94ae\u5931\u53bb\u7126\u70b9\uff0c\u4ece\u800c\u6e05\u9664\u80cc\u666f\u8272\u3002 clickhandler(evt) { let target = evt.target; if(target.nodename == &#8220;span&#8221;){ target = evt.target.parentnode; } target.blur(); \/\/ \u5f3a\u5236\u6309\u94ae\u5931\u53bb\u7126\u70b9 } \u767b\u5f55\u540e\u590d\u5236 2. \u91cd\u5199 \u6837\u5f0f\uff1a \u53ef\u4ee5\u4f7f\u7528 css \u6837\u5f0f\u6765\u91cd\u5199\u6309\u94ae\u7684\u9ed8\u8ba4\u884c\u4e3a\u3002\u5c06\u4ee5\u4e0b\u6837\u5f0f\u6dfb\u52a0\u5230\u4f60\u7684\u9879\u76ee\u4e2d\uff1a .buttonDiv, .buttonDiv:focus:not(.buttonDiv:hover){ \/* \u9f20\u6807\u70b9\u51fb\u540e\u79fb\u5f00\uff0c\u6062\u590d\u672c\u8eab\u6837\u5f0f *\/ background: white; } .buttonDiv:focus, .buttonDiv:hover{ \/* \u9f20\u6807\u60ac\u6d6e\uff0c\u6ca1\u6709\u6309\u4e0b\uff1b\u9f20\u6807\u6309\u4e0b\u540e\u62ac\u8d77\uff0c\u6ca1\u6709\u79fb\u5f00 *\/ background: [&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-25976","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25976","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=25976"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25976\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}