<!doctype html> <html> <head> <meta charset="UTF-8"> <title>事件綁定</title> <script src="js/vue.js"></script> </head> <body> <div id="container"> <p>{{msg}}</p> <h5>表單提交</h5> <form v-on:submit.prevent="handleSubmit"> <input type="checkbox" v-bind:checked="isChecked" v-on:click="handleDisabled"/> 是否同意本站協議 <br> <button v-bind:disabled="isDisabled">提交</button> </form> </div> <script> new Vue({ el:"#container", data:{ msg:"Hello VueJs", isDisabled:false, isChecked:false }, //methods對象 methods:{ //通過methods來定義需要的方法 handleDisabled:function(){ this.isChecked = !this.isChecked; if(this.isChecked==true){ this.isDisabled = true; } else{ this.isDisabled = false; } } } }) </script> </body> </html>