From 68c5ef7d9fea3f911e250fb5f8b300bc76099e49 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 26 十月 2023 13:55:49 +0800
Subject: [PATCH] 小程序
---
minipro_standard/uni_modules/uview-ui/components/u-grid/u-grid.vue | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/minipro_standard/uni_modules/uview-ui/components/u-grid/u-grid.vue b/minipro_standard/uni_modules/uview-ui/components/u-grid/u-grid.vue
new file mode 100644
index 0000000..b43cc27
--- /dev/null
+++ b/minipro_standard/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