123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <view
- class="u-grid"
- ref='u-grid'
- :style="[gridStyle]"
- >
- <slot />
- </view>
- </template>
- <script>
- import { props } from './props';
- import { mpMixin } from '../../libs/mixin/mpMixin';
- import { mixin } from '../../libs/mixin/mixin';
- import { addStyle, deepMerge } from '../../libs/function/index';
-
- export default {
- name: 'u-grid',
- mixins: [mpMixin, mixin, props],
- data() {
- return {
- index: 0,
- width: 0
- }
- },
- watch: {
-
- parentData() {
- if (this.children.length) {
- this.children.map(child => {
-
- typeof(child.updateParentData) == 'function' && child.updateParentData();
- })
- }
- },
- },
- created() {
-
- this.children = []
- },
- computed: {
-
- parentData() {
- return [this.hoverClass, this.col, this.size, this.border];
- },
-
- gridStyle() {
- let style = {};
- switch (this.align) {
- case 'left':
- style.justifyContent = 'flex-start';
- break;
- case 'center':
- style.justifyContent = 'center';
- break;
- case 'right':
- style.justifyContent = 'flex-end';
- break;
- default:
- style.justifyContent = 'flex-start';
- };
- return deepMerge(style, addStyle(this.customStyle));
- }
- },
- emits: ['click'],
-
-
- options: {
-
- },
-
- methods: {
-
- childClick(name) {
- this.$emit('click', name)
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/components.scss";
- $u-grid-width:100% !default;
- .u-grid {
-
- width: $u-grid-width;
- position: relative;
- box-sizing: border-box;
- overflow: hidden;
- display: block;
-
- justify-content: center;
- @include flex;
- flex-wrap: wrap;
- align-items: center;
-
-
-
- display: grid;
- grid-gap: v-bind(gap);
- grid-template-columns: repeat(v-bind(col), 1fr);
-
- }
- </style>
|