{"id":551,"date":"2023-12-21T10:24:47","date_gmt":"2023-12-21T02:24:47","guid":{"rendered":"http:\/\/ericw.top\/?p=551"},"modified":"2023-12-21T10:24:47","modified_gmt":"2023-12-21T02:24:47","slug":"%e6%8c%87%e4%bb%a4%e8%a1%a5%e5%85%85","status":"publish","type":"post","link":"http:\/\/ericw.top\/?p=551","title":{"rendered":"\u6307\u4ee4\u8865\u5145"},"content":{"rendered":"<h2 id=\"toc-0\">\u6307\u4ee4\u8865\u5145<\/h2>\n<h2 id=\"toc-1\">\u6307\u4ee4\u4fee\u9970\u7b26<\/h2>\n<p>\u901a\u8fc7<code class=\"prettyprint\" >.<\/code>\u6307\u660e\u4e00\u4e9b\u6307\u4ee4\u540e\u7f00\uff0c\u4e0d\u540c\u7684\u540e\u6700\u5c01\u88c5\u4e86\u4e0d\u540c\u7684\u5904\u7406\u64cd\u4f5c    \u7b80\u5316\u4ee3\u7801<\/p>\n<p><strong>\u2460 \u6309\u952e\u4fee\u9970\u7b26<\/strong> <\/p>\n<p>\u200b   <code class=\"prettyprint\" >@keyup.enter <\/code><\/p>\n<p>\u200b   \u2192 \u952e\u76d8\u56de\u8f66\u76d1\u542c <\/p>\n<p><strong>\u2461 v-model\u4fee\u9970\u7b26<\/strong> <\/p>\n<p>\u200b   <code class=\"prettyprint\" >v-model.trim<\/code> \u2192 \u53bb\u9664\u9996\u5c3e\u7a7a\u683c <\/p>\n<p>\u200b   <code class=\"prettyprint\" >v-model.number<\/code> \u2192 \u8f6c\u6570\u5b57 <\/p>\n<p><strong>\u2462 \u4e8b\u4ef6\u4fee\u9970\u7b26<\/strong> <\/p>\n<p>\u200b   <code class=\"prettyprint\" >@\u4e8b\u4ef6\u540d.stop<\/code> \u2192 \u963b\u6b62\u5192\u6ce1 <\/p>\n<p>\u200b   <code class=\"prettyprint\" >@\u4e8b\u4ef6\u540d.prevent<\/code> \u2192 \u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a <\/p>\n<p>\u4f8b\uff1a<code class=\"prettyprint\" >@keyup.enter<\/code>  \u56de\u8f66\u89e6\u53d1 fn \u51fd\u6570<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">    &lt;input @keyup.enter=&quot;fn&quot; v-model=&quot;username&quot; type=&quot;text&quot;&gt;<\/code><\/pre>\n<p>\u4f8b\uff1a\u56db\u4e2a\u4fee\u9970\u7b26\u7684\u7528\u6cd5\uff1a<code class=\"prettyprint\" >.trim<\/code>  <code class=\"prettyprint\" >.number<\/code>  <code class=\"prettyprint\" >.stop<\/code>  <code class=\"prettyprint\" >.prevent<\/code><\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">  &lt;div id=&quot;app&quot;&gt;\n    &lt;h3&gt;v-model\u4fee\u9970\u7b26 .trim .number&lt;\/h3&gt;\n    \u59d3\u540d\uff1a&lt;input v-model.trim=&quot;username&quot; type=&quot;text&quot;&gt;&lt;br&gt;\n    \u5e74\u7eaa\uff1a&lt;input v-model.number=&quot;age&quot; type=&quot;text&quot;&gt;&lt;br&gt;\n\n    &lt;h3&gt;@\u4e8b\u4ef6\u540d.stop \u2192 \u963b\u6b62\u5192\u6ce1&lt;\/h3&gt;\n    &lt;div @click=&quot;fatherFn&quot; class=&quot;father&quot;&gt;\n      &lt;div @click.stop=&quot;sonFn&quot; class=&quot;son&quot;&gt;\u513f\u5b50&lt;\/div&gt;\n    &lt;\/div&gt;\n\n    &lt;h3&gt;@\u4e8b\u4ef6\u540d.prevent \u2192 \u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a&lt;\/h3&gt;\n    &lt;a @click.prevent href=&quot;http:\/\/www.baidu.com&quot;&gt;\u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a&lt;\/a&gt;\n  &lt;\/div&gt;\n  &lt;script src=&quot;.\/vue.js&quot;&gt;&lt;\/script&gt;\n  &lt;script&gt;\n    const app = new Vue({\n      el: &#039;#app&#039;,\n      data: {\n        username: &#039;&#039;,\n        age: &#039;&#039;,\n      },\n      methods: {\n        fatherFn() {\n          alert(&#039;\u8001\u7236\u4eb2\u88ab\u70b9\u51fb\u4e86&#039;)\n        },\n        sonFn() {\n          alert(&#039;\u513f\u5b50\u88ab\u70b9\u51fb\u4e86&#039;)\n        }\n      }\n    })\n  &lt;\/script&gt;<\/code><\/pre>\n<h2 id=\"toc-2\">v-bind\u5bf9\u4e8e\u6837\u5f0f\u64cd\u4f5c\u7684\u589e\u5f3a<\/h2>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><code class=\"prettyprint\" >class=&quot;\u5bf9\u8c61\/\u6570\u636e&quot;<\/code><\/p>\n<p>1\u3001<strong>\u5bf9\u8c61<\/strong>  \u952e\u5c31\u662f\u7c7b\u540d\uff0c\u503c\u662f\u5e03\u5c14\u503c\u3002\u5982\u679c\u503c\u4e3a true\uff0c\u6709\u8fd9\u4e2a\u7c7b\uff0c\u5426\u5219\u6ca1\u6709\u8fd9\u4e2a\u7c7b<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">&lt;div class=&quot;box&quot;:class=&quot;{\u7c7b\u540d1: \u5e03\u5c14\u503c\uff0c\u7c7b\u540d2: \u5e03\u5c14\u503c}&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<p><strong>\u9002\u7528\u573a\u666f\uff1a<\/strong>\u4e00\u4e2a\u7c7b\u540d\u6765\u56de\u5207\u6362<\/p>\n<p>2\u3001<strong>\u6570\u7ec4<\/strong>   \u6570\u7ec4\u4e2d\u6240\u6709\u7684\u7c7b\uff0c\u90fd\u4f1a\u6dfb\u52a0\u5230\u76d2\u5b50\u4e0a\uff0c\u672c\u8d28\u5c31\u662f\u4e00\u4e2a class \u5217\u8868<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">&lt;div class=&quot;box&quot;:class=&quot;[\u7c7b\u540d1,\u7c7b\u540d2,\u7c7b\u540d3]&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<p><strong>\u9002\u7528\u573a\u666f\uff1a<\/strong>\u6279\u91cf\u6dfb\u52a0\u6216\u5220\u9664\u7c7b<\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">  &lt;div id=&quot;app&quot;&gt;\n    &lt;div class=&quot;box&quot; :class=&quot; {pink:true,big:false}&quot;&gt;\u9ed1\u9a6c\u7a0b\u5e8f\u5458&lt;\/div&gt;\n    &lt;div class=&quot;box&quot; :class=&quot;[&#039;pink&#039;,&#039;big&#039;]&quot;&gt;\u9ed1\u9a6c\u7a0b\u5e8f\u5458&lt;\/div&gt;\n  &lt;\/div&gt;<\/code><\/pre>\n<h2 id=\"toc-3\">v-bind\u5bf9\u4e8e\u6837\u5f0fstyle\u7684\u63a7\u5236<\/h2>\n<p><strong>\u8bed\u6cd5 :<\/strong>style = &quot;\u6837\u5f0f\u5bf9\u8c61&quot; <\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">&lt;div class=&quot;box&quot; :style=&quot;{ CSS\u5c5e\u6027\u540d1: CSS\u5c5e\u6027\u503c, CSS\u5c5e\u6027\u540d2: CSS\u5c5e\u6027\u503c }&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<p><strong>\u9002\u7528\u573a\u666f\uff1a<\/strong>\u67d0\u4e2a\u5177\u4f53\u5c5e\u6027\u7684\u52a8\u6001\u8bbe\u7f6e<\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">&lt;div class=&quot;box&quot; :style=&quot;{width:&#039;&#039;,height:&#039;&#039;,backgroundColor:&#039;pink&#039;}&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<h2 id=\"toc-4\">v-model \u5e94\u7528\u4e8e\u5176\u4ed6\u8868\u5355\u5143\u7d20<\/h2>\n<p>\u5e38\u89c1\u7684\u8868\u5355\u5143\u7d20\u90fd\u53ef\u4ee5\u7528 v-model \u7ed1\u5b9a\u5173\u8054 \u2192 \u5feb\u901f \u83b7\u53d6 \u6216 \u8bbe\u7f6e \u8868\u5355\u5143\u7d20\u7684\u503c <\/p>\n<p>\u5b83\u4f1a\u6839\u636e \u63a7\u4ef6\u7c7b\u578b \u81ea\u52a8\u9009\u53d6 \u6b63\u786e\u7684\u65b9\u6cd5 \u6765\u66f4\u65b0\u5143\u7d20 <\/p>\n<p>\u8f93\u5165\u6846 <code class=\"prettyprint\" >input:text<\/code>   \u2192 <code class=\"prettyprint\" >value <\/code><\/p>\n<p>\u6587\u672c\u57df <code class=\"prettyprint\" >textarea<\/code>   \u2192 <code class=\"prettyprint\" >checked<\/code> <\/p>\n<p>\u590d\u9009\u6846 <code class=\"prettyprint\" >input:checkbox<\/code>   \u2192<code class=\"prettyprint\" > value<\/code> <\/p>\n<p>\u5355\u9009\u6846 <code class=\"prettyprint\" >input:radio<\/code>   \u2192 <code class=\"prettyprint\" >value<\/code> <\/p>\n<p>\u4e0b\u62c9\u83dc\u5355 <code class=\"prettyprint\" >select<\/code>   \u2192<code class=\"prettyprint\" > checked<\/code><\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-html\">  &lt;div id=&quot;app&quot;&gt;\n    &lt;h3&gt;\u5c0f\u9ed1\u5b66\u4e60\u7f51&lt;\/h3&gt;\n\n    \u59d3\u540d\uff1a\n    &lt;input type=&quot;text&quot; v-model=&quot;username&quot;&gt;\n    &lt;br&gt;&lt;br&gt;\n\n    \u662f\u5426\u5355\u8eab\uff1a\n    &lt;input type=&quot;checkbox&quot; v-model=&quot;isSingle&quot;&gt;\n    &lt;br&gt;&lt;br&gt;\n\n    &lt;!-- \n      \u524d\u7f6e\u7406\u89e3\uff1a\n        1. name:  \u7ed9\u5355\u9009\u6846\u52a0\u4e0a name \u5c5e\u6027 \u53ef\u4ee5\u5206\u7ec4 \u2192 \u540c\u4e00\u7ec4\u4e92\u76f8\u4f1a\u4e92\u65a5\n        2. value: \u7ed9\u5355\u9009\u6846\u52a0\u4e0a value \u5c5e\u6027\uff0c\u7528\u4e8e\u63d0\u4ea4\u7ed9\u540e\u53f0\u7684\u6570\u636e\n      \u7ed3\u5408 Vue \u4f7f\u7528 \u2192 v-model\n    --&gt;\n    \u6027\u522b:\n    &lt;input v-model=&quot;gender&quot; type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;1&quot; v-model=&quot;&quot;&gt;\u7537\n    &lt;input v-model=&quot;gender&quot; type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;2&quot; v-model=&quot;&quot;&gt;\u5973\n    &lt;br&gt;&lt;br&gt;\n\n    &lt;!-- \n      \u524d\u7f6e\u7406\u89e3\uff1a\n        1. option \u9700\u8981\u8bbe\u7f6e value \u503c\uff0c\u63d0\u4ea4\u7ed9\u540e\u53f0\n        2. select \u7684 value \u503c\uff0c\u5173\u8054\u4e86\u9009\u4e2d\u7684 option \u7684 value \u503c\n      \u7ed3\u5408 Vue \u4f7f\u7528 \u2192 v-model\n    --&gt;\n    \u6240\u5728\u57ce\u5e02:\n    &lt;select v-model=&quot;cityId&quot;&gt;\n      &lt;option v-model=&quot;&quot; value=&quot;101&quot;&gt;\u5317\u4eac&lt;\/option&gt;\n      &lt;option v-model=&quot;&quot; value=&quot;102&quot;&gt;\u4e0a\u6d77&lt;\/option&gt;\n      &lt;option v-model=&quot;&quot; value=&quot;103&quot;&gt;\u6210\u90fd&lt;\/option&gt;\n      &lt;option v-model=&quot;&quot; value=&quot;104&quot;&gt;\u5357\u4eac&lt;\/option&gt;\n    &lt;\/select&gt;\n    &lt;br&gt;&lt;br&gt;\n\n    \u81ea\u6211\u63cf\u8ff0\uff1a\n    &lt;textarea v-model=&quot;desc&quot;&gt;&lt;\/textarea&gt;\n\n    &lt;button&gt;\u7acb\u5373\u6ce8\u518c&lt;\/button&gt;\n  &lt;\/div&gt;\n  &lt;script src=&quot;.\/vue.js&quot;&gt;&lt;\/script&gt;\n  &lt;script&gt;\n    const app = new Vue({\n      el: &#039;#app&#039;,\n      data: {\n        username: &#039;&#039;,\n        isSingle: true,\n        gender: &#039;1&#039;,\n        cityId: &#039;101&#039;,\n        desc: &#039;&#039;,\n      }\n    })\n  &lt;\/script&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6307\u4ee4\u8865\u5145 \u6307\u4ee4\u4fee\u9970\u7b26 \u901a\u8fc7.\u6307\u660e\u4e00\u4e9b\u6307\u4ee4\u540e\u7f00\uff0c\u4e0d\u540c\u7684\u540e\u6700\u5c01\u88c5\u4e86\u4e0d\u540c\u7684\u5904\u7406\u64cd\u4f5c \u7b80\u5316\u4ee3\u7801 \u2460 \u6309\u952e\u4fee\u9970\u7b26 \u200b @ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,5],"tags":[],"_links":{"self":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/551"}],"collection":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=551"}],"version-history":[{"count":1,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":552,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/551\/revisions\/552"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/media\/542"}],"wp:attachment":[{"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}