123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <view
- class="fs-grid-item"
- :class="{ 'fs-grid-item-border': border, 'fs-grid-item-radius': radius }"
- :style="{ padding: padding ? '20rpx 0' : 0, backgroundColor: bgColor }"
- @click="handleClick"
- >
- <slot></slot>
- </view>
- </template>
- <script>
- /**
- * 宫格项组件
- * @description 宫格项组件
- * @property {String} link 跳转地址
- * @property {String} linkType 跳转类型
- */
- export default {
- name: 'fs-grid-item'
- }
- </script>
- <script setup>
- import { inject } from 'vue'
- const props = defineProps({
- link: String,
- linkType: {
- type: String,
- default: 'navigateTo'
- }
- })
- const emits = defineEmits(['click'])
- const gird = inject('fsGrid', {})
- const { border, padding, bgColor, radius } = gird
- const handleClick = () => {
- if (props.link) {
- uni[props.linkType]({
- url: props.link
- })
- }
- emits('click')
- }
- </script>
- <style lang="scss" scoped>
- .fs-grid-item {
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- text-align: center;
- position: relative;
- height: 100%;
- background-color: #fff;
- &-border::before {
- position: absolute;
- content: '';
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- border: 1px solid var(--border-color);
- margin-left: -1px;
- margin-top: -1px;
- }
- &-radius {
- border-radius: var(--radius);
- }
- }
- </style>
|