automated_uniapp/uni_modules/cool-ui/components/cl-grid-item/cl-grid-item.vue

29 lines
489 B
Vue
Raw Normal View History

2025-01-09 16:16:11 +08:00
<template>
<view class="cl-grid-item" :style="{ width }">
<slot></slot>
</view>
</template>
<script lang="ts">
import { computed, defineComponent } from "vue";
import { getParent } from "/@/cool/utils";
export default defineComponent({
name: "cl-grid-item",
setup() {
// cl-grid
const parent = getParent("cl-grid", ["column"]);
// 宽度
const width = computed(() => {
return 100 / (parent.value?.column || 0) + "%";
});
return {
width,
};
},
});
</script>