From d1448cb0ef10f358bb7bddb4e1ec268515e0b787 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 15 七月 2025 11:46:57 +0800
Subject: [PATCH] 项目初始化

---
 uni_modules/uview-ui/components/u-grid/u-grid.vue |   97 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/uni_modules/uview-ui/components/u-grid/u-grid.vue b/uni_modules/uview-ui/components/u-grid/u-grid.vue
new file mode 100644
index 0000000..b43cc27
--- /dev/null
+++ b/uni_modules/uview-ui/components/u-grid/u-grid.vue
@@ -0,0 +1,97 @@
+<template>
+	<view
+	    class="u-grid"
+		ref='u-grid'
+	    :style="[gridStyle]"
+	>
+		<slot />
+	</view>
+</template>
+
+<script>
+	import props from './props.js';
+	/**
+	 * grid 瀹牸甯冨眬
+	 * @description 瀹牸缁勪欢涓�鑸敤浜庡悓鏃跺睍绀哄涓悓绫婚」鐩殑鍦烘櫙锛屽彲浠ョ粰瀹牸鐨勯」鐩缃窘鏍囩粍浠�(badge)锛屾垨鑰呭浘鏍囩瓑锛屼篃鍙互鎵╁睍涓哄乏鍙虫粦鍔ㄧ殑杞挱褰㈠紡銆�
+	 * @tutorial https://www.uviewui.com/components/grid.html
+	 * @property {String | Number}	col			瀹牸鐨勫垪鏁帮紙榛樿 3 锛�
+	 * @property {Boolean}			border		鏄惁鏄剧ず瀹牸鐨勮竟妗嗭紙榛樿 false 锛�
+	 * @property {String}			align		瀹牸瀵归綈鏂瑰紡锛岃〃鐜颁负鏁伴噺灏戠殑鏃跺�欙紝闈犲乏锛屽眳涓紝杩樻槸闈犲彸 锛堥粯璁� 'left' 锛�
+	 * @property {Object}			customStyle	瀹氫箟闇�瑕佺敤鍒扮殑澶栭儴鏍峰紡
+	 * @event {Function} click 鐐瑰嚮瀹牸瑙﹀彂
+	 * @example <u-grid :col="3" @click="click"></u-grid>
+	 */
+	export default {
+		name: 'u-grid',
+		mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
+		data() {
+			return {
+				index: 0,
+				width: 0
+			}
+		},
+		watch: {
+			// 褰撶埗缁勪欢闇�瑕佸瓙缁勪欢闇�瑕佸叡浜殑鍙傛暟鍙戠敓浜嗗彉鍖栵紝鎵嬪姩閫氱煡瀛愮粍浠�
+			parentData() {
+				if (this.children.length) {
+					this.children.map(child => {
+						// 鍒ゆ柇瀛愮粍浠�(u-radio)濡傛灉鏈塽pdateParentData鏂规硶鐨勮瘽锛屽氨灏辨墽琛�(鎵ц鐨勭粨鏋滄槸瀛愮粍浠堕噸鏂颁粠鐖剁粍浠舵媺鍙栦簡鏈�鏂扮殑鍊�)
+						typeof(child.updateParentData) == 'function' && child.updateParentData();
+					})
+				}
+			},
+		},
+		created() {
+			// 濡傛灉灏哻hildren瀹氫箟鍦╠ata涓紝鍦ㄥ井淇″皬绋嬪簭浼氶�犳垚寰幆寮曠敤鑰屾姤閿�
+			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 uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
+			}
+		},
+		methods: {
+			// 姝ゆ柟娉曠敱u-grid-item瑙﹀彂锛岀敤浜庡湪u-grid鍙戝嚭浜嬩欢
+			childClick(name) {
+				this.$emit('click', name)
+			}
+		}
+	};
+</script>
+
+<style lang="scss" scoped>
+	@import "../../libs/css/components.scss";
+     $u-grid-width:100% !default;
+	.u-grid {
+		/* #ifdef MP */
+		width: $u-grid-width;
+		position: relative;
+		box-sizing: border-box;
+		overflow: hidden;
+		display: block;
+		/* #endif */
+		justify-content: center;
+		@include flex;
+		flex-wrap: wrap;
+		align-items: center;
+	}
+</style>

--
Gitblit v1.9.3