{"id":299,"date":"2018-10-31T09:45:42","date_gmt":"2018-10-31T01:45:42","guid":{"rendered":"http:\/\/www.yinyubo.cn\/?p=299"},"modified":"2022-05-17T09:45:16","modified_gmt":"2022-05-17T01:45:16","slug":"vue","status":"publish","type":"post","link":"https:\/\/www.yinyubo.com\/?p=299","title":{"rendered":"vue\u6846\u67b6html\u4e2d\u7684script\u5185\u5bb9\u8f6c\u6362\u6210.vue\u6587\u4ef6\u7684script\u5185\u5bb9"},"content":{"rendered":"<p>\u95ee\u9898\uff1a<br \/>\n1.\u56e0\u4e3a\u524d\u6bb5\u65f6\u95f4\u5b66\u4e60vue\uff0c\u90fd\u662f\u5728\u4e00\u4e2aindex.html\u4e2d\u6dfb\u52a0&lt;html&gt;\u548c&lt;script&gt;<br \/>\n2.\u5982\u679c\u4f7f\u7528.vue\u6587\u4ef6\uff0c&lt;template&gt;\u5bf9\u5e94index.html&lt;html&gt;\u4f5c\u4e3a\u5c55\u793a\u5c42\uff0c&lt;script&gt;\u4f5c\u4e3a\u903b\u8f91\u5c42\u5bf9\u5e94index.html\u7684&lt;script&gt;<br \/>\nhtml\u4e2d\u7528\u7684\u662fnew vue\u3002\u800c.vue\u6587\u4ef6\u4e2d\u7528\u7684\u662fexport default\u3002\u4e0b\u9762\u662f\u5bf9\u6bd4<\/p>\n<ul>\n<li>index.html<\/li>\n<\/ul>\n<pre class=\"lang:python decode:true\"><code class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&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;div id=\"app\"&gt;&lt;\/div&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<ul>\n<li>.vue\u6587\u4ef6<\/li>\n<\/ul>\n<pre class=\"lang:python decode:true \"><code class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">&lt;template&gt;\n  &lt;div class=\"hello\"&gt;\n    &lt;h1&gt;{{ msg }}&lt;\/h1&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 class=\"btn btn-large btn-primary\" v-on:click=\"login\"&gt;\u767b\u5f55&lt;\/button&gt;\n  &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n&lt;script&gt;\nexport default {\n  name: \"hello\",\n  data() {\n    return {\n      msg: \"\u6b22\u8fce\u6765\u5230\u6d4b\u8bd5\u5f00\u53d1\u7b14\u8bb0\uff01\",\n      checkedNames:[],\n      username: \"\",\n      password: \"\",\n    };\n  },\n  methods:{\n    login(){\n       alert('\u7528\u6237\u540d\u662f:'+this.username+',\u5bc6\u7801\u662f:'+this.password+'\uff0c\u9009\u62e9\u7684\u662f:'+this.checkedNames)\n    }\n  }\n};\n&lt;\/script&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\uff1a 1.\u56e0\u4e3a\u524d\u6bb5\u65f6\u95f4\u5b66\u4e60vue\uff0c\u90fd\u662f\u5728\u4e00\u4e2aindex.html\u4e2d\u6dfb\u52a0&lt;html&gt;\u548c&lt;sc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-299","post","type-post","status-publish","format-standard","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/299","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=299"}],"version-history":[{"count":1,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":943,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions\/943"}],"wp:attachment":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}