diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md
index 9943f3f0c..168d1dc7a 100644
--- a/docs/markdown/changelog.zh-CN.md
+++ b/docs/markdown/changelog.zh-CN.md
@@ -2,11 +2,19 @@
### [v2.0.0-beta.4](https://github.com/youzan/vant/tree/v2.0.0-beta.4)
+##### Checkbox
+
+- 修复`label-position`不生效的问题
+
##### Field
- 新增`click`事件
- 新增`clickable`属性
+##### Radio
+
+- 修复`label-position`不生效的问题
+
##### Stepper
- 支持`Number`类型的`input-width`属性
diff --git a/packages/checkbox/index.less b/packages/checkbox/index.less
index d31a2beaa..f48b16464 100644
--- a/packages/checkbox/index.less
+++ b/packages/checkbox/index.less
@@ -59,7 +59,6 @@
line-height: @checkbox-size;
&--left {
- float: left;
margin: 0 @checkbox-label-margin 0 0;
}
diff --git a/packages/checkbox/test/__snapshots__/index.spec.js.snap b/packages/checkbox/test/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..10f69f18b
--- /dev/null
+++ b/packages/checkbox/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,15 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`label disabled 1`] = `
+
+`;
+
+exports[`label-position prop 1`] = `
+
+`;
diff --git a/packages/checkbox/test/index.spec.js b/packages/checkbox/test/index.spec.js
index 5920d5899..d42933bd1 100644
--- a/packages/checkbox/test/index.spec.js
+++ b/packages/checkbox/test/index.spec.js
@@ -31,8 +31,8 @@ test('disabled', () => {
test('label disabled', () => {
const wrapper = mount(Checkbox, {
- slots: {
- default: ''
+ scopedSlots: {
+ default: () => 'Label'
},
propsData: {
labelDisabled: true
@@ -41,6 +41,7 @@ test('label disabled', () => {
wrapper.find('.van-checkbox__label').trigger('click');
expect(wrapper.emitted('input')).toBeFalsy();
+ expect(wrapper).toMatchSnapshot();
});
test('checkbox group', async () => {
@@ -91,3 +92,16 @@ test('click event', () => {
icon.trigger('click');
expect(onClick).toHaveBeenCalledTimes(2);
});
+
+test('label-position prop', () => {
+ const wrapper = mount(Checkbox, {
+ scopedSlots: {
+ default: () => 'Label'
+ },
+ propsData: {
+ labelPosition: 'left'
+ }
+ });
+
+ expect(wrapper).toMatchSnapshot();
+});
diff --git a/packages/mixins/checkbox.js b/packages/mixins/checkbox.js
index 5cf729395..6977ac441 100644
--- a/packages/mixins/checkbox.js
+++ b/packages/mixins/checkbox.js
@@ -62,6 +62,22 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
);
+ const Children = [
+
+ {CheckIcon}
+
+ ];
+
+ if (this.labelPosition === 'left') {
+ Children.unshift(Label);
+ } else {
+ Children.push(Label);
+ }
+
return (
({
this.$emit('click', event);
}}
>
-
- {CheckIcon}
-
- {Label}
+ {Children}
);
}
diff --git a/packages/radio/index.less b/packages/radio/index.less
index 138623f21..010c9d3dd 100644
--- a/packages/radio/index.less
+++ b/packages/radio/index.less
@@ -59,7 +59,6 @@
line-height: @radio-size;
&--left {
- float: left;
margin: 0 @radio-label-margin 0 0;
}