123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <view class="u-grid-item" :hover-class="parentData.hoverClass"
- :hover-stay-time="200" @tap="click" :style="{
- background: bgColor,
- width: width,
- }">
- <view class="u-grid-item-box" :style="[customStyle]" :class="[parentData.border ? 'u-border-right u-border-bottom' : '']">
- <slot />
- </view>
- </view>
- </template>
- <script>
-
- export default {
- name: "u-grid-item",
- props: {
-
- bgColor: {
- type: String,
- default: '#ffffff'
- },
-
- index: {
- type: [Number, String],
- default: ''
- },
-
- customStyle: {
- type: Object,
- default() {
- return {
- padding: '30rpx 0'
- }
- }
- }
- },
- data() {
- return {
- parentData: {
- hoverClass: '',
- col: 3,
- border: true,
- }
- };
- },
- created() {
-
- this.updateParentData();
-
- this.parent.children.push(this);
- },
- computed: {
-
- width() {
- return 100 / Number(this.parentData.col) + '%';
- },
- },
- methods: {
-
- updateParentData() {
-
- this.getParentData('u-grid');
- },
- click() {
- this.$emit('click', this.index);
- this.parent && this.parent.click(this.index);
- }
- }
- };
- </script>
- <style scoped lang="scss">
- @import "../../libs/css/style.components.scss";
-
- .u-grid-item {
- box-sizing: border-box;
- background: #fff;
- @include vue-flex;
- align-items: center;
- justify-content: center;
- position: relative;
- flex-direction: column;
-
- /* #ifdef MP */
- position: relative;
- float: left;
- /* #endif */
- }
- .u-grid-item-hover {
- background: #f7f7f7 !important;
- }
- .u-grid-marker-box {
- position: absolute;
- /* #ifndef APP-NVUE */
- display: inline-flex;
- /* #endif */
- line-height: 0;
- }
- .u-grid-marker-wrap {
- position: absolute;
- }
- .u-grid-item-box {
- padding: 30rpx 0;
- @include vue-flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- flex: 1;
- width: 100%;
- height: 100%;
- }
- </style>
|