{"id":285,"date":"2018-10-23T14:34:58","date_gmt":"2018-10-23T06:34:58","guid":{"rendered":"http:\/\/www.yinyubo.cn\/?p=285"},"modified":"2022-05-17T09:45:30","modified_gmt":"2022-05-17T01:45:30","slug":"vue-2","status":"publish","type":"post","link":"https:\/\/www.yinyubo.com\/?p=285","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Vue\u83b7\u5f97\u591a\u4e2ainput\u548c\u591a\u9009\u6846\u7684\u503c\uff0c\u4ee5\u53ca\u53cc\u5411\u7ed1\u5b9a"},"content":{"rendered":"<h1><\/h1>\n<h1><strong>\u9700\u6c42\u5206\u6790<\/strong><\/h1>\n<p>1.\u6709\u4e09\u4e2a\u591a\u9009\u6846\u9009\u9879\u3002\u5f53\u9009\u62e9\u4e0d\u540c\u7684\u6309\u94ae\u65f6\uff0c\u754c\u9762\u4e0a\u4f1a\u5b9e\u65f6\u5c55\u793a\u6240\u9009\u7684\u53c2\u6570<br \/>\n2.\u6709\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5f53\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u65f6\uff0c\u754c\u9762\u4e0a\u4f1a\u5b9e\u65f6\u5c55\u793a\u6240\u8f93\u5165\u7684\u53c2\u6570<br \/>\n3.\u5f53\u70b9\u51fb\u767b\u5f55\u6309\u94ae\u7684\u65f6\u5019\uff0c\u4f1a\u5f39\u51faalert\uff0c\u5c55\u793a\u5f53\u524d\u6240\u9009\u7684\u6240\u6709\u53c2\u6570<\/p>\n<h1><strong>\u5b9e\u73b0\u4ee3\u7801<\/strong><\/h1>\n<p>\u901a\u8fc7v-model\u5b9e\u65f6\u83b7\u5f97input\u7684\u8f93\u5165\u503c\u3002\u901a\u8fc7v-on\u76d1\u542clogin\u4e8b\u4ef6\u3002\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b<\/p>\n<pre class=\"lang:python decode:true\"><code class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n  &lt;meta charset=\"utf-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\"&gt;\n  &lt;title&gt;vueapp01&lt;\/title&gt;\n  &lt;script src=\"https:\/\/cdn.staticfile.org\/vue\/2.4.2\/vue.min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n&lt;style&gt;\n  .class1{\n    background: #444;\n    color: #eee;\n  }\n&lt;\/style&gt;\n&lt;body&gt;\n  &lt;!-- &lt;div id=\"app\"&gt;&lt;\/div&gt; --&gt;\n  &lt;div id='example-3'&gt;\n    &lt;input type=\"checkbox\" id=\"jack\" value=\"\u767d\u91d1\u4f1a\u5458\" v-model=\"checkedNames\"&gt;\n    &lt;label for=\"jack\"&gt;\u767d\u91d1\u4f1a\u5458&lt;\/label&gt;\n    &lt;input type=\"checkbox\" id=\"john\" value=\"\u9ec4\u91d1\u4f1a\u5458\" v-model=\"checkedNames\"&gt;\n    &lt;label for=\"john\"&gt;\u9ec4\u91d1\u4f1a\u5458&lt;\/label&gt;\n    &lt;input type=\"checkbox\" id=\"mike\" value=\"\u738b\u8005\u4f1a\u5458\" v-model=\"checkedNames\"&gt;\n    &lt;label for=\"mike\"&gt;\u738b\u8005\u4f1a\u5458&lt;\/label&gt;\n    &lt;br&gt;\n    &lt;span&gt;\u9009\u62e9\u4f1a\u5458\u79cd\u7c7b: {{ checkedNames }}&lt;\/span&gt;\n  &lt;\/div&gt;\n  &lt;div id=\"app2\"&gt;\n    &lt;input v-model=\"username\" placeholder=\"\u7528\u6237\u540d\"&gt;\n    &lt;p&gt;\u7528\u6237\u540d\u662f: {{ username }}&lt;\/p&gt;\n    &lt;input  type=\"password\" v-model=\"password\" placeholder=\"\u5bc6\u7801\"&gt;\n    &lt;p&gt;\u5bc6\u7801\u662f: {{ password }}&lt;\/p&gt;\n    &lt;button v-on:click=\"login\"&gt;\u767b\u5f55&lt;\/button&gt;\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;script type=\"text\/javascript\"&gt;\n  var chenames=new Vue({\n    el: '#example-3',\n    data: {\n      checkedNames: []\n    }\n  })\n  var user=new Vue({\n    el :'#app2',\n    data: {\n      username:'',\n      password:''\n    },\n    methods :{\n      login:function(event){\n        alert('\u7528\u6237\u540d\u662f:'+this.username+',\u5bc6\u7801\u662f:'+this.password+'\uff0c\u9009\u62e9\u7684\u662f:'+chenames.checkedNames)\n      }\n    }\n  })\n&lt;\/script&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42\u5206\u6790 1.\u6709\u4e09\u4e2a\u591a\u9009\u6846\u9009\u9879\u3002\u5f53\u9009\u62e9\u4e0d\u540c\u7684\u6309\u94ae\u65f6\uff0c\u754c\u9762\u4e0a\u4f1a\u5b9e\u65f6\u5c55\u793a\u6240\u9009\u7684\u53c2\u6570 2.\u6709\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5f53\u8f93\u5165\u7528\u6237 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":286,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=285"}],"version-history":[{"count":1,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/285\/revisions"}],"predecessor-version":[{"id":945,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/285\/revisions\/945"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/media\/286"}],"wp:attachment":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}