123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <template>
- <view class="u-col" :class="[
- 'u-col-' + span
- ]" :style="{
- padding: `0 ${Number(gutter)/2 + 'rpx'}`,
- marginLeft: 100 / 12 * offset + '%',
- flex: `0 0 ${100 / 12 * span}%`,
- alignItems: uAlignItem,
- justifyContent: uJustify,
- textAlign: textAlign
- }"
- @tap="click">
- <slot></slot>
- </view>
- </template>
- <script>
-
- export default {
- name: "u-col",
- props: {
-
- span: {
- type: [Number, String],
- default: 12
- },
-
- offset: {
- type: [Number, String],
- default: 0
- },
-
- justify: {
- type: String,
- default: 'start'
- },
-
- align: {
- type: String,
- default: 'center'
- },
-
- textAlign: {
- type: String,
- default: 'left'
- },
-
- stop: {
- type: Boolean,
- default: true
- }
- },
- data() {
- return {
- gutter: 20,
- }
- },
- created() {
- this.parent = false;
- },
- mounted() {
-
- this.parent = this.$u.$parent.call(this, 'u-row');
- if (this.parent) {
- this.gutter = this.parent.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(e) {
- this.$emit('click');
- }
- }
- }
- </script>
- <style lang="scss">
- @import "../../libs/css/style.components.scss";
- .u-col {
-
- float: left;
-
- }
- .u-col-0 {
- width: 0;
- }
- .u-col-1 {
- width: calc(100%/12);
- }
- .u-col-2 {
- width: calc(100%/12 * 2);
- }
- .u-col-3 {
- width: calc(100%/12 * 3);
- }
- .u-col-4 {
- width: calc(100%/12 * 4);
- }
- .u-col-5 {
- width: calc(100%/12 * 5);
- }
- .u-col-6 {
- width: calc(100%/12 * 6);
- }
- .u-col-7 {
- width: calc(100%/12 * 7);
- }
- .u-col-8 {
- width: calc(100%/12 * 8);
- }
- .u-col-9 {
- width: calc(100%/12 * 9);
- }
- .u-col-10 {
- width: calc(100%/12 * 10);
- }
- .u-col-11 {
- width: calc(100%/12 * 11);
- }
- .u-col-12 {
- width: calc(100%/12 * 12);
- }
- </style>
|