{"id":978,"date":"2023-03-23T22:41:43","date_gmt":"2023-03-23T14:41:43","guid":{"rendered":""},"modified":"2023-03-23T22:41:43","modified_gmt":"2023-03-23T14:41:43","slug":"Vue.js \u4e8b\u4ef6","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/978.html","title":{"rendered":"Vue.js \u4e8b\u4ef6"},"content":{"rendered":"
\n
<button v-on:click=\"clickHandler\"><\/button><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4fbf\u6377\u7684\u901f\u8bb0
\n @ <\/strong>\u4ee3\u66ffv-on\u6307\u4ee4\u3002\u770b\u8d77\u6765\u50cf\u8fd9\u6837:\n <\/div>\n\n <button @click=\"clickHandler\"><\/button><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u6211\u4eec\u5728v-on\u6307\u4ee4\u4e2d\u6dfb\u52a0\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u8fd9\u5c06\u662f\u6211\u4eec\u8981\u5904\u7406\u7684\u4e8b\u4ef6\u7684\u540d\u79f0\u3002\u5728\u4e0a\u8ff0\u793a\u4f8b\u60c5\u51b5\u4e0b\uff0c\u8fd9\u662f\u4e00\u4e2aclick\u4e8b\u4ef6\u3002\u4e4b\u540e\uff0c\u6211\u4eec\u5fc5\u987b\u5c06\u8868\u8fbe\u5f0f\u7ed1\u5b9a\u5230\u6307\u4ee4\uff0c\u8be5\u6307\u4ee4\u901a\u5e38\u662f\u60a8\u8981\u7528\u4e8e\u5904\u7406\u4e8b\u4ef6\u7684\u65b9\u6cd5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5c06\u5176\u79f0\u4e3aclickHandler\u3002\n <\/div>\n\u60a8\u53ef\u4ee5\u5904\u7406\u7684Vue.js\u4e8b\u4ef6\u7684\u7c7b\u578b<\/h3>\n\n \u60a8\u53ef\u4ee5\u5904\u7406\u5f88\u591a\u5176\u4ed6\u7684Vue.js\u9664\u70b9\u51fb\u4e4b\u5916\u7684DOM\u4e8b\u4ef6\u3002 Vue.js\u53ef\u4ee5\u5904\u7406\u4efb\u4f55\u7c7b\u578b\u7684Web\u6216\u79fb\u52a8\u672c\u673a\u4e8b\u4ef6\u4ee5\u53ca\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u3002\u901a\u5e38\u7528\u4e8e\u5904\u7406\u7684\u6700\u5e38\u89c1\u4e8b\u4ef6:\n <\/div>\n submit<\/span>
\n keyup <\/span>
\n drag<\/span>
\n scroll<\/span>
\n error<\/span>
\n abort<\/span>
\n mouseover<\/span>
\n mouseout<\/span>
\n load\u7b49<\/span> <\/p>\n\u4e8b\u4ef6\u5904\u7406\u65b9\u6cd5<\/h2>\n\n \u8ba9\u6211\u4eec\u770b\u4e00\u4e9b\u90e8\u7f72\u4e8b\u4ef6\u5904\u7406\u65b9\u6cd5\u7684\u7b80\u5355\u793a\u4f8b\u3002\n <\/div>\n\u70b9\u51fb\u4e8b\u4ef6<\/h3>\n\n \u8bf7\u53c2\u89c1\u4ee5\u4e0b\u793a\u4f8b\uff0c\u4ee5\u6f14\u793aVue.js\u4e2d\u7684\u70b9\u51fb\u4e8b\u4ef6\u5904\u7406\u3002\n <\/div>\n\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n\n <html><\/span>
<head><\/span>
<title><\/span>Vue.js Event Handling<\/title><\/span>
<link rel=\"stylesheet\" href=\"index.css\">
<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
<\/head><\/span>
<body><\/span>
<div id=\"app\">
<button v-on:click = \"displaynumbers\">Click Me to Add No.<\/button><\/span>
<h2><\/span> Add Number 100 + 200 = {{total}}<\/h2><\/span>
<\/div><\/span>
<script src=\"index.js\"><\/script><\/span>
<\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n\n var vm = new Vue({
el: \"#app\",
data: {
num1: 50,
num2 : 100,
total : ''
},
methods : {
displaynumbers : function(event) {
console.log(event);
return this.total = this.num1+ this.num2;
}
},
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684CSS\u6587\u4ef6\u4f7f\u8f93\u51fa\u66f4\u5177\u5438\u5f15\u529b\u3002\n <\/div>\n\n Index.css\u6587\u4ef6: <\/strong>\n <\/div>\n\n html, body {
margin: 5px;
padding: 0;
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n\n \u8f93\u51fa: <\/strong>\n <\/div>\n
<\/p>\n
\n \u5355\u51fb\u4e0a\u9762\u7684\u6309\u94ae\u65f6\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u5b83\u5df2\u7ecf\u6dfb\u52a0\u4e86\u53f7\u7801\u3002\u53c2\u89c1\u8f93\u51fa:\n <\/div>\n
<\/p>\n
\u793a\u4f8b\u8bf4\u660e<\/h3>\n\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4e3aDOM\u5143\u7d20\u5206\u914d\u4e86\u4ee5\u4e0bclick\u4e8b\u4ef6\u3002\n <\/div>\n\n <button v-on:click = \"displaynumbers\">Click Me to Add No.<\/button><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u5f53\u60a8\u5355\u51fb\u6309\u94ae\u65f6\uff0c\u5b83\u5c06\u8c03\u7528\u65b9\u6cd5\"
\n displaynumbers <\/strong>\"\uff0c\u8be5\u65b9\u6cd5\u5c06\u5728\u4e8b\u4ef6\u4e2d\u63a5\u6536\u5e76\u770b\u5230\u8f93\u51fa\u3002\n <\/div>\n\n \u6211\u4eec\u8fd8\u53ef\u4ee5\u5206\u914d
\n @ <\/strong>\u7684\u7f29\u5199\uff0c\u800c\u4e0d\u662fv-on\u6307\u4ee4\u3002\u60a8\u53ef\u4ee5\u8c03\u7528\u4ee5\u4e0b\u4e8b\u4ef6\uff0c\u7ed3\u679c\u5c06\u76f8\u540c\u3002\n <\/div>\n\n <button @click = \"displaynumbers\">Click ME<\/button><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\u9f20\u6807\u60ac\u505c\u548c\u9f20\u6807\u79fb\u51fa\u4e8b\u4ef6<\/h3>\n\n \u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u68c0\u67e5\u4e24\u4e2a\u65b0\u7684\u540d\u4e3a
\n mouseover <\/strong>\u548c
\n mouseout <\/strong>\u7684Vue.js\u4e8b\u4ef6\u3002\u8bf7\u53c2\u89c1\u4ee5\u4e0b\u793a\u4f8b\u3002\n <\/div>\n\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n\n <html><\/span>
<head><\/span>
<title><\/span>Vue.js Event Handling<\/title><\/span>
<link rel=\"stylesheet\" href=\"index.css\">
<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
<\/head><\/span>
<body><\/span>
<div id = \"databinding\">
<div v-bind:style = \"styleobj\" v-on:mouseover = \"changebgcolor\" v-on:mouseout = \"originalcolor\"><\/div><\/span>
<\/div><\/span>
<script src=\"index.js\"><\/script><\/span>
<\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n\n var vm = new Vue({
el: '#databinding',
data: {
num1: 100,
num2 : 200,
total : '',
styleobj : {
width:\"100px\",
height:\"100px\",
backgroundColor:\"red\"
}
},
methods : {
changebgcolor : function() {
this.styleobj.backgroundColor = \"blue\";
},
originalcolor : function() {
this.styleobj.backgroundColor = \"brown\";
}
},
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n\n \u8f93\u51fa: <\/strong>\n <\/div>\n
<\/p>\n
\n \u60a8\u53ef\u4ee5\u5728\u8f93\u51fa\u4e2d\u770b\u5230\u9ed8\u8ba4\u80cc\u666f\u8272\u4e3a
\n \u7ea2\u8272<\/strong>\u3002\u73b0\u5728\uff0c\u5c06\u9f20\u6807\u5149\u6807\u79fb\u5230\u8be5\u6846\u4e0a\uff0c\u8be5\u6846\u7684\u989c\u8272\u5c06\u66f4\u6539\u4e3a
\n \u84dd\u8272<\/strong>\u3002\u53c2\u89c1\u8f93\u51fa\u3002\n <\/div>\n
<\/p>\n
\n \u73b0\u5728\uff0c\u5c06\u9f20\u6807\u5149\u6807\u79fb\u51fa\u6846\uff0c\u5e76\u4e14\u6846\u7684\u989c\u8272\u5c06\u66f4\u6539\u4e3a
\n \u68d5\u8272<\/strong>\u3002\u53c2\u89c1\u8f93\u51fa\u3002\n <\/div>\n
<\/p>\n
\u793a\u4f8b\u8bf4\u660e<\/h3>\n\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2adiv\u5143\u7d20\uff0c\u5176\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u4e3a100px\u3002\u8be5div\u7684\u9ed8\u8ba4\u80cc\u666f\u989c\u8272\u662f\u7ea2\u8272\u3002\u5728
\n \u9f20\u6807\u60ac\u505c<\/strong>\u4e0a\uff0c\u80cc\u666f\u989c\u8272\u66f4\u6539\u4e3a\u84dd\u8272\uff0c\u5728
\n \u9f20\u6807\u60ac\u505c<\/strong>\u4e0a\u80cc\u666f\u989c\u8272\u66f4\u6539\u4e3a\u68d5\u8272\u3002\n <\/div>\n\n \u5728\u9f20\u6807\u60ac\u505c\u671f\u95f4\uff0c\u79f0\u4e3achangebgcolor\uff0c\u5c06\u9f20\u6807\u79fb\u51fadiv\u540e\uff0c\u4e00\u79cd\u65b9\u6cd5\u79f0\u4e3aoriginalcolor\u3002\n <\/div>\n\n <div v-bind:style = \"styleobj\" v-on:mouseover = \"changebgcolor\" v-on:mouseout = \"originalcolor\"><\/div><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e24\u4e2a\u4e8b\u4ef6mouseover\u548cmouseout\u5e76\u5c06\u5b83\u4eec\u5206\u914d\u7ed9div\u3002\n <\/div>\n\n \u4f7f\u7528
\n v-bind: style =\"styleobj\" <\/strong>\u5c06\u76f8\u540c\u7684\u53d8\u91cf\u7ed1\u5b9a\u5230div\u3002 \u3002\u5728changebgcolor\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06\u989c\u8272\u66f4\u6539\u4e3a\u7eff\u8272\u3002\n <\/div>\n\n changebgcolor : function() {
this.styleobj.backgroundColor = \"blue\";
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u4f7f\u7528stylobj\u53d8\u91cf\uff0c\u989c\u8272\u53d8\u4e3a\u7eff\u8272\u3002\u540c\u6837\uff0c\u6211\u4eec\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06\u989c\u8272\u66f4\u6539\u4e3a\u68d5\u8272\n <\/div>\n\n originalcolor : function() {
this.styleobj.backgroundColor = \"brown\";
<\/span><\/code><\/pre>\n<\/p><\/div>\n Vue.js\u4e8b\u4ef6\u4fee\u9970\u7b26<\/h3>\n\n Vue.js\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5728v-on\u5c5e\u6027\u4e0a\u53ef\u7528\u7684\u4e8b\u4ef6\u4fee\u9970\u7b26\u3002\u6211\u4eec\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u8c03\u7528event.preventDefault()\u6216event.stopPropagation()\u3002\u8fd9\u91cc\uff0c.prevent\u548c.stop\u662f\u4e8b\u4ef6\u4fee\u9970\u7b26\u3002\n <\/div>\n\n \u8fd9\u4e9b\u4fee\u9970\u7b26\u662f\u7528\u70b9\u8868\u793a\u7684\u6307\u4ee4\u540e\u7f00\u3002\u4ee5\u4e0b\u662fv-on\u5c5e\u6027\u4e0a\u53ef\u7528\u7684\u6700\u5e38\u89c1\u4fee\u9970\u7b26\u7684\u5217\u8868:\n <\/div>\n .once <\/span>
\n .prevent <\/span>
\n .stop <\/span>
\n .capture <\/span>
\n .self <\/span>
\n .passive <\/span> <\/p>\n.once\u4e8b\u4ef6\u4fee\u9970\u7b26<\/h3>\n\n \u5b83\u4ec5\u5141\u8bb8\u4e8b\u4ef6\u6267\u884c\u4e00\u6b21\u3002\n <\/div>\n\n \u8bed\u6cd5: <\/strong>\n <\/div>\n\n <button v-on:click.once = \"buttonclicked\">Click Once<\/button><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u5fc5\u987b\u5728\u8c03\u7528\u4fee\u9970\u7b26\u65f6\u6dfb\u52a0\u70b9\u8fd0\u7b97\u7b26\uff0c\u5982\u4e0a\u9762\u7684\u8bed\u6cd5\u6240\u793a\u3002\n <\/div>\n\n \u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u4ee5\u4e86\u89e3\u4e00\u6b21\u4fee\u9970\u7b26\u7684\u6982\u5ff5\u548c\u5de5\u4f5c\u539f\u7406\u3002\n <\/div>\n\n \u793a\u4f8b<\/strong>\n <\/div>\n\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n\n <html><\/span>
<head><\/span>
<title><\/span>Vue.js Event Handling<\/title><\/span>
<link rel=\"stylesheet\" href=\"index.css\">
<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
<\/head><\/span>
<body><\/span>
<div id = \"eg_2\">
<button v-on:click.once = \"buttonclickedonce\" v-bind:style = \"styleobj\">Just once clickable<\/button><\/span>
Output:{{clicknum}}
<br\/><br\/>
<button v-on:click = \"buttonclicked\" v-bind:style = \"styleobj\">Click Me anytime<\/button><\/span>
Output:{{clicknum1}}
<\/div><\/span>
<script src=\"index.js\"><\/script><\/span>
<\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n\n var vm = new Vue({
el: '#eg_2',
data: {
clicknum : 0,
clicknum1 :0,
styleobj: {
backgroundColor: '#2196F3!important',
cursor: 'pointer',
padding: '8px 16px',
verticalAlign: 'middle',
}
},
methods : {
buttonclickedonce : function() {
this.clicknum++;
},
buttonclicked : function() {
this.clicknum1++;
}
}
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n\n \u8f93\u51fa: <\/strong>\n <\/div>\n
<\/p>\n
\n \u60a8\u53ef\u4ee5\u770b\u5230\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u6309\u94ae\u3002\u5e26\u6709\"\u53ea\u9700\u5355\u51fb\u4e00\u6b21\"\u6807\u7b7e\u7684\u6309\u94ae\u6dfb\u52a0\u4e86\u4e00\u6b21\u4fee\u9970\u7b26\uff0c\u800c\u53e6\u4e00\u4e2a\u6309\u94ae\u5219\u6ca1\u6709\u4efb\u4f55\u4fee\u9970\u7b26\u3002\n <\/div>\n\n <button v-on:click.once = \"buttonclickedonce\" v-bind:style = \"styleobj\">Just once clickable<\/button><\/span>
<button v-on:click = \"buttonclicked\" v-bind:style = \"styleobj\">Click Me anytime<\/button><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u5f53\u60a8\u5355\u51fb\u7b2c\u4e00\u4e2a\u6309\u94ae\u65f6\uff0c\u5b83\u5c06\u8c03\u7528\u65b9\u6cd5\" buttonclickedonce\"\uff0c\u800c\u5728\u5355\u51fb\u7b2c\u4e8c\u4e2a\u6309\u94ae\u540e\uff0c\u5b83\u5c06\u8c03\u7528\u65b9\u6cd5\" buttonclicked\"\u3002\n <\/div>\n\n buttonclickedonce : function() {
this.clicknum++;
},
buttonclicked : function() {
this.clicknum1++;
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u6211\u4eec\u8fd8\u5728
\n clicknum <\/strong>\u548c
\n clicknum1 <\/strong>\u4e2d\u5b9a\u4e49\u4e86\u4e24\u4e2a\u53d8\u91cf\u3002\u5355\u51fb\u6309\u94ae\u65f6\uff0c\u4e24\u8005\u90fd\u4f1a\u589e\u52a0\u3002\u8fd9\u4e24\u4e2a\u53d8\u91cf\u90fd\u521d\u59cb\u5316\u4e3a0\u3002\u60a8\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u8f93\u51fa\u4e2d\u770b\u5230\u5b83\u3002\n <\/div>\n\n \u5355\u51fb\u7b2c\u4e00\u4e2a\u6309\u94ae\u65f6\uff0c\u53d8\u91cfclicknum\u9012\u589e1\u3002\u5728\u7b2c\u4e8c\u6b21\u5355\u51fb\u65f6\uff0c\u6570\u5b57\u4e0d\u9012\u589e\u4e3a\u4fee\u9970\u7b26\u53ef\u9632\u6b62\u5176\u6267\u884c\u6216\u6267\u884c\u5355\u51fb\u6309\u94ae\u65f6\u5206\u914d\u7684\u4efb\u4f55\u64cd\u4f5c\u9879\u3002\n <\/div>\n\n \u5355\u51fb\u7b2c\u4e8c\u4e2a\u6309\u94ae\u65f6\uff0c\u5c06\u6267\u884c\u76f8\u540c\u7684\u64cd\u4f5c\uff0c\u5373\u53d8\u91cf\u589e\u52a0\u3002\u6bcf\u6b21\u5355\u51fb\u65f6\uff0c\u8be5\u503c\u90fd\u4f1a\u589e\u52a0\u5e76\u663e\u793a\u3002\u8bf7\u53c2\u9605\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
<\/p>\n
\n \u5728\u4e24\u6b21\u5355\u51fb\u4e24\u4e2a\u6309\u94ae\u4e4b\u540e\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u7b2c\u4e00\u4e2a\u6309\u94ae\u4ec5\u663e\u793a\u4e00\u6b21\u5355\u51fb\uff0c\u7b2c\u4e8c\u4e2a\u6309\u94ae\u663e\u793a\u4e865\u6b21\u3002\n <\/div>\n\u3002prevent\u4e8b\u4ef6\u4fee\u9970\u7b26<\/h3>\n\n \u4f7f\u7528\u4e86.prevent\u4e8b\u4ef6\u4fee\u9970\u7b26\u5f53\u60a8\u4e0d\u60f3\u901a\u8fc7\u5355\u51fb\u6309\u94ae\u6253\u5f00\u7279\u5b9a\u7684ID\u6216URL\u65f6\u3002\n <\/div>\n\n \u8bed\u6cd5: <\/strong>\n <\/div>\n\n <a href = \"An specific url\" v-on:click.prevent = \"clickme\">Click Me<\/a><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u8ba9\u6211\u4eec\u770b\u4e24\u4e2a\u793a\u4f8b\uff0c\u4e00\u4e2a\u4e0d\u5e26.prevent\u4e8b\u4ef6\u4fee\u9970\u7b26\uff0c\u53e6\u4e00\u4e2a\u5e26\u5b83\u6e05\u695a\u5730\u7406\u89e3\u5b83\u3002\n <\/div>\n\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n\n <html><\/span>
<head><\/span>
<title><\/span>Vue.js Event Handling<\/title><\/span>
<link rel=\"stylesheet\" href=\"index.css\">
<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
<\/head><\/span>
<body><\/span>
<div id = \"eg_3\">
<a href = \"http:\/\/www.google.com\" v-on:click = \"clickme\" target = \"_blank\" v-bind:style = \"styleobj\">Click Me<\/a><\/span>
<\/div><\/span>
<script src=\"index.js\"><\/script><\/span>
<\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n\n var vm = new Vue({
el: '#eg_3',
data: {
clicknum : 0,
clicknum1 :0,
styleobj: {
color: '#4CAF50',
marginLeft: '20px',
fontSize: '30px'
}
},
methods : {
clickme : function() {
alert(\"Anchor tag is clicked\");
}
}
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n\n \u8f93\u51fa: <\/strong>\n <\/div>\n