我想实现的功能是
在directive
update
时往data.users['0']
里面增加一个checked = true
使用的vue
版本是1.0.18
//注册directive代码
Vue.directive('selectedAll', require('../components/selectedAll'))
//directive代码
<script type="text/javascript">
export default {
twoWay: true,
params: ['selecteds'], //selecteds就是外部传入的对象
update (val) {
}
};
</script>
<!--html代码-->
<input type="checkbox" v-model="selectedAll"
v-selected-all="selectedAll" :selecteds="data.users">
<!--
data.users 的值是这样的
{ "0": { "id": "85", "name": "中文", "create_time": "2016-09-23", "userName": "aa" }, "1": { "id": "86", "name": "English", "create_time": "2016-09-23", "userName": "aa" }, "2": { "id": "87", "name": "Français", "create_time": "2016-09-23", "userName": "aa" } }
-->