vue判断一个复选框的选中状态

<body>
    <div id="app">
        <input type="checkbox"  @click = "select(event)"> {{checkedStatus}}
    </div>
</body>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            checkedStatus:"未选中"
        },
        methods: {
            select:function(e) {
                if(e.target.checked == true) {
                    //当判断复选框被选中时,可以做一些处理事件
                    this.checkedStatus = "选中";
                } else {
                    this.checkedStatus = "未选中";
                }
            }
        },
    })
</script>
Logo

前往低代码交流专区

更多推荐