feat(Row): add wrap prop (#8393)
This commit is contained in:
+6
-1
@@ -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?.()}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&--nowrap {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
&--justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
Reference in New Issue
Block a user