vue的radio选项框添加点击事件

vue的radio选项框添加点击事件要加在外层的lable中,不能加在input中。另外,vue属性监听无法监听对象类型

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 测试实例</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body>
<div id = "app">
<label class="radio-inline" v-if="!bool.info" v-for="vo in enums.accountType" @click="chosen">
  <input type="radio" name="accountType" :value="vo.value" v-model="entity.accountType"/> {{vo.text}}
</label>
</div>
<script type = "text/javascript">
var vm = new Vue({
    el: '#app',
    data: {
        bool: { info: false, accountMain: false},
        entity: {accountType:""},
        enums: {accountType:[{value:"a",text:"a"},{value:"b",text:"b"}]},
    },
    methods: {
        chosen:function(){
            alert("触发事件"+vm.entity.accountType);
            
        },
    },
    watch: {
        entity: function (val) {
            alert("属性监听"+val)
        },
    deep: true
    },
});
</script>
</body>
</html>

 

posted @ 2020-12-28 11:17  缀满繁星的夜空  阅读(1069)  评论(0)    收藏  举报