{"id":8482,"date":"2023-11-28T20:29:29","date_gmt":"2023-11-28T12:29:29","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8482"},"modified":"2023-12-02T22:55:00","modified_gmt":"2023-12-02T14:55:00","slug":"vue-zhongvue-chang-yong-de-xiu-shi-fu-2","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/vue-zhongvue-chang-yong-de-xiu-shi-fu-2\/","title":{"rendered":"Vue \u4e2d vue \u5e38\u7528\u7684\u4fee\u9970\u7b26\uff1f"},"content":{"rendered":"<p>Vue \u63d0\u4f9b\u4e86\u4e00\u4e9b\u4fee\u9970\u7b26\uff0c\u7528\u4e8e\u5bf9\u6307\u4ee4\u884c\u4e3a\u8fdb\u884c\u589e\u5f3a\u6216\u4fee\u6539\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 Vue \u4fee\u9970\u7b26\uff1a<\/p>\n<h3><a id=\"1-prevent\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>1. <code>.prevent<\/code><\/h3>\n<p>\u963b\u6b62\u9ed8\u8ba4\u4e8b\u4ef6\u7684\u53d1\u751f\u3002<\/p>\n<pre><code class=\"language-html\">&lt;form @submit.prevent=&quot;onSubmit&quot;&gt;...&lt;\/form&gt;\n<\/code><\/pre>\n<h3><a id=\"2-stop\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>2. <code>.stop<\/code><\/h3>\n<p>\u963b\u6b62\u4e8b\u4ef6\u5192\u6ce1\u3002<\/p>\n<pre><code class=\"language-html\">&lt;div @click.stop=&quot;onClick&quot;&gt;...&lt;\/div&gt;\n<\/code><\/pre>\n<h3><a id=\"3-capture\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>3. <code>.capture<\/code><\/h3>\n<p>\u4e8b\u4ef6\u4fa6\u542c\u5668\u4f1a\u5728\u6355\u83b7\u9636\u6bb5\u89e6\u53d1\u3002<\/p>\n<pre><code class=\"language-html\">&lt;div @click.capture=&quot;onClick&quot;&gt;...&lt;\/div&gt;\n<\/code><\/pre>\n<h3><a id=\"4-self\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>4. <code>.self<\/code><\/h3>\n<p>\u53ea\u5f53\u4e8b\u4ef6\u662f\u4ece\u4fa6\u542c\u5668\u7ed1\u5b9a\u7684\u5143\u7d20\u672c\u8eab\u89e6\u53d1\u65f6\u624d\u89e6\u53d1\u56de\u8c03\u3002<\/p>\n<pre><code class=\"language-html\">&lt;div @click.self=&quot;onClick&quot;&gt;...&lt;\/div&gt;\n<\/code><\/pre>\n<h3><a id=\"5-once\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>5. <code>.once<\/code><\/h3>\n<p>\u4e8b\u4ef6\u53ea\u89e6\u53d1\u4e00\u6b21\u3002<\/p>\n<pre><code class=\"language-html\">&lt;button @click.once=&quot;onClick&quot;&gt;...&lt;\/button&gt;\n<\/code><\/pre>\n<h3><a id=\"6-passive\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>6. <code>.passive<\/code><\/h3>\n<p>\u6307\u793a\u4e8b\u4ef6\u7684\u9ed8\u8ba4\u884c\u4e3a\u4e0d\u4f1a\u88ab\u963b\u6b62\u3002<\/p>\n<pre><code class=\"language-html\">&lt;div @touchstart.passive=&quot;onTouchStart&quot;&gt;...&lt;\/div&gt;\n<\/code><\/pre>\n<h3><a id=\"7-native\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>7. <code>.native<\/code><\/h3>\n<p>\u76d1\u542c\u7ec4\u4ef6\u6839\u5143\u7d20\u7684\u539f\u751f\u4e8b\u4ef6\u3002<\/p>\n<pre><code class=\"language-html\">&lt;MyComponent @click.native=&quot;onClick&quot;&gt;...&lt;\/MyComponent&gt;\n<\/code><\/pre>\n<h3><a id=\"8-sync\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>8. <code>.sync<\/code><\/h3>\n<p>\u7528\u4e8e\u5728\u5b50\u7ec4\u4ef6\u4e2d\u66f4\u65b0\u7236\u7ec4\u4ef6\u7684\u503c\u3002<\/p>\n<pre><code class=\"language-html\">&lt;!-- \u5b50\u7ec4\u4ef6 --&gt;\n&lt;button @click=&quot;$emit('update:isOpen', !isOpen)&quot;&gt;Toggle&lt;\/button&gt;\n\n&lt;!-- \u7236\u7ec4\u4ef6 --&gt;\n&lt;ChildComponent :isOpen.sync=&quot;isOpen&quot;&gt;&lt;\/ChildComponent&gt;\n<\/code><\/pre>\n<p>\u8fd9\u4e9b\u4fee\u9970\u7b26\u53ef\u4ee5\u7528\u4e8e\u4e8b\u4ef6\u76d1\u542c\u3001\u8868\u5355\u8f93\u5165\u7b49\u573a\u666f\u4e2d\uff0c\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u63a7\u5236\u4e8b\u4ef6\u7684\u884c\u4e3a\u6216\u8005\u7b80\u5316\u67d0\u4e9b\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u63d0\u4f9b\u4e86\u4e00\u4e9b\u4fee\u9970\u7b26\uff0c\u7528\u4e8e\u5bf9\u6307\u4ee4\u884c\u4e3a\u8fdb\u884c\u589e\u5f3a\u6216\u4fee\u6539\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 Vue \u4fee\u9970\u7b26\uff1a 1. .preve [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114],"tags":[],"class_list":["post-8482","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=8482"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8482\/revisions"}],"predecessor-version":[{"id":14120,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8482\/revisions\/14120"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8482"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}