feat(Row): add wrap prop (#8393)

This commit is contained in:
neverland
2021-03-23 13:05:52 +08:00
committed by GitHub
parent 71d60cdca0
commit 49430a1ef6
5 changed files with 23 additions and 1 deletions
+6 -1
View File
@@ -31,6 +31,10 @@ export default defineComponent({
type: String as PropType<keyof HTMLElementTagNameMap>,
default: 'div',
},
wrap: {
type: Boolean,
default: true,
},
gutter: {
type: [Number, String],
default: 0,
@@ -86,12 +90,13 @@ export default defineComponent({
linkChildren({ spaces });
return () => {
const { tag, align, justify } = props;
const { tag, wrap, align, justify } = props;
return (
<tag
class={bem({
[`align-${align}`]: align,
[`justify-${justify}`]: justify,
nowrap: !wrap,
})}
>
{slots.default?.()}
+4
View File
@@ -2,6 +2,10 @@
display: flex;
flex-wrap: wrap;
&--nowrap {
flex-wrap: nowrap;
}
&--justify-center {
justify-content: center;
}
+11
View File
@@ -0,0 +1,11 @@
import { Row } from '..';
import { mount } from '../../../test';
test('should add "van-row--nowrap" class when wrap prop is false', () => {
const wrapper = mount(Row, {
props: {
wrap: false,
},
});
expect(wrapper.classes()).toContain('van-row--nowrap');
});