feat(Form): support using rate

This commit is contained in:
陈嘉涵 2020-02-10 17:01:56 +08:00
parent 1db9536182
commit 1cde0b4d52
2 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,10 @@
<van-switch v-model="switchChecked" slot="input" size="24" /> <van-switch v-model="switchChecked" slot="input" size="24" />
</van-field> </van-field>
<van-field name="rate" :label="$t('rate')">
<van-rate v-model="rate" slot="input" />
</van-field>
<div style="margin: 16px;"> <div style="margin: 16px;">
<van-button type="info" round block>{{ $t('submit') }}</van-button> <van-button type="info" round block>{{ $t('submit') }}</van-button>
</div> </div>
@ -20,6 +24,7 @@
export default { export default {
i18n: { i18n: {
'zh-CN': { 'zh-CN': {
rate: '评分',
submit: '提交', submit: '提交',
switch: '开关', switch: '开关',
checkbox: '复选框', checkbox: '复选框',
@ -27,6 +32,7 @@ export default {
requireCheckbox: '请勾选复选框', requireCheckbox: '请勾选复选框',
}, },
'en-US': { 'en-US': {
rate: 'Rate',
submit: 'Submit', submit: 'Submit',
switch: 'Switch', switch: 'Switch',
checkbox: 'Checkbox', checkbox: 'Checkbox',
@ -37,6 +43,7 @@ export default {
data() { data() {
return { return {
rate: 3,
checkbox: false, checkbox: false,
switchChecked: false, switchChecked: false,
}; };

View File

@ -1,6 +1,12 @@
// Utils
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit } from '../utils';
import { preventDefault } from '../utils/dom/event'; import { preventDefault } from '../utils/dom/event';
// Mixins
import { TouchMixin } from '../mixins/touch'; import { TouchMixin } from '../mixins/touch';
import { FieldMixin } from '../mixins/field';
// Components
import Icon from '../icon'; import Icon from '../icon';
const [createComponent, bem] = createNamespace('rate'); const [createComponent, bem] = createNamespace('rate');
@ -18,7 +24,7 @@ function getRateStatus(value, index, allowHalf) {
} }
export default createComponent({ export default createComponent({
mixins: [TouchMixin], mixins: [TouchMixin, FieldMixin],
props: { props: {
size: [Number, String], size: [Number, String],