<template>
<view class="u-row" :style="{
alignItems: uAlignItem,
justifyContent: uJustify
}"
@tap.stop.prevent="click"
>
<slot />
</view>
</template>
<script>
export default {
name: "u-row",
props: {
gutter: {
type: [String, Number],
default: 20
},
justify: {
type: String,
default: 'start'
},
align: {
type: String,
default: 'center'
}
},
provide() {
return {
gutter: this.gutter
}
},
computed: {
uJustify() {
if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify;
else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify;
else return this.justify;
},
uAlignItem() {
if (this.align == 'top') return 'flex-start';
if (this.align == 'bottom') return 'flex-end';
else return this.align;
}
},
methods: {
click() {
this.$emit('click');
}
}
}
</script>
<style lang="scss">
@import "../../libs/css/style.components.scss";
.u-row {
// 由于微信小程序编译后奇怪的页面结构,只能使用float布局实现,flex无法实现
display: flex;
flex-wrap: wrap;
}
.u-row:after {
display: table;
clear: both;
content: "";
}
</style>