docs(Rate): add change event demo (#5596)
This commit is contained in:
+20
-1
@@ -39,6 +39,13 @@
|
||||
<demo-block :title="$t('readonly')">
|
||||
<van-rate v-model="value6" readonly />
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="$t('changeEvent')">
|
||||
<van-rate
|
||||
v-model="value7"
|
||||
@change="onChange"
|
||||
/>
|
||||
</demo-block>
|
||||
</demo-section>
|
||||
</template>
|
||||
|
||||
@@ -52,6 +59,8 @@ export default {
|
||||
customStyle: '自定义样式',
|
||||
customCount: '自定义数量',
|
||||
readonly: '只读状态',
|
||||
changeEvent: '监听 change 事件',
|
||||
toastContent: (value) => `当前值:${value}`
|
||||
},
|
||||
'en-US': {
|
||||
halfStar: 'Half Star',
|
||||
@@ -60,7 +69,9 @@ export default {
|
||||
customStyle: 'Custom Style',
|
||||
customCount: 'Custom Count',
|
||||
readonly: 'Readonly',
|
||||
},
|
||||
changeEvent: 'Change Event',
|
||||
toastContent: (value) => `current value:${value}`
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -71,8 +82,16 @@ export default {
|
||||
value4: 2.5,
|
||||
value5: 4,
|
||||
value6: 3,
|
||||
value7: 2
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
onChange(value) {
|
||||
this.value7 = value;
|
||||
this.$toast(this.$t('toastContent', value));
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user