Skip to content

Commit

Permalink
fix(Radio): add event change
Browse files Browse the repository at this point in the history
  • Loading branch information
vvpvvp committed Dec 3, 2018
1 parent 48f092f commit aa3dde3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
19 changes: 19 additions & 0 deletions doc/components/component/form/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,24 @@
<td>全局config <code>dict.titleName</code></td>
</tr>
</table>

<h3>Radio 事件</h3>
<table class="table">
<tr>
<th>事件</th>
<th>说明</th>
<th>返回数据</th>
</tr>
<tr>
<td>change</td>
<td>当数据产生变动的时候触发</td>
<td>完整对象</td>
</tr>
<tr>
<td>input</td>
<td>当数据产生变动的时候触发</td>
<td>当前绑定的v-model值</td>
</tr>
</table>
</div>
</template>
7 changes: 6 additions & 1 deletion doc/components/demos/form/radio1.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<p v-color:gray>{{value1}}</p>
<div><Radio v-model="value1" :datas="param1"></Radio></div>
<div><Radio v-model="value1" :datas="param1" @change="change"></Radio></div>
<p v-color:gray>{{value2}}</p>
<div><Radio v-model="value2" :datas="param2"></Radio></div>
<p v-color:gray>{{value3}}</p>
Expand All @@ -23,6 +23,11 @@ export default {
param2: { 1: '选择1', 2: '选择2', 3: '选择3' },
param3: [{ title: '选择1', key: 'a1', other: '其他值' }, { title: '选择2', key: 'a2' }, { title: '选择3', key: 'a3' }],
}
},
methods: {
change(data) {
log('change', data)
}
}
};
</script>
19 changes: 19 additions & 0 deletions doc/components_en/component/form/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,24 @@
<td>config <code>dict.titleName</code></td>
</tr>
</table>

<h3>Radio Event</h3>
<table class="table">
<tr>
<th>Event</th>
<th>Description</th>
<th>Return value</th>
</tr>
<tr>
<td>change</td>
<td>When data changed</td>
<td>total object value</td>
</tr>
<tr>
<td>input</td>
<td>When data changed</td>
<td>v-model value</td>
</tr>
</table>
</div>
</template>
1 change: 1 addition & 0 deletions src/components/radio/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
result = value[this.key];
}
this.$emit('input', result);
this.$emit('change', value);
let event = document.createEvent("CustomEvent");
event.initCustomEvent("setvalue", true, true, result);
this.$el.dispatchEvent(event);
Expand Down

0 comments on commit aa3dde3

Please sign in to comment.