From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- uview-ui/components/u-collapse/u-collapse.vue | 99 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 99 insertions(+), 0 deletions(-) diff --git a/uview-ui/components/u-collapse/u-collapse.vue b/uview-ui/components/u-collapse/u-collapse.vue new file mode 100644 index 0000000..8572957 --- /dev/null +++ b/uview-ui/components/u-collapse/u-collapse.vue @@ -0,0 +1,99 @@ +<template> + <view class="u-collapse"> + <slot /> + </view> +</template> + +<script> + /** + * collapse 鎵嬮鐞� + * @description 閫氳繃鎶樺彔闈㈡澘鏀剁撼鍐呭鍖哄煙 + * @tutorial https://www.uviewui.com/components/collapse.html + * @property {Boolean} accordion 鏄惁鎵嬮鐞存ā寮忥紙榛樿true锛� + * @property {Boolean} arrow 鏄惁鏄剧ず鏍囬鍙充晶鐨勭澶达紙榛樿true锛� + * @property {String} arrow-color 鏍囬鍙充晶绠ご鐨勯鑹诧紙榛樿#909399锛� + * @property {Object} head-style 鏍囬鑷畾涔夋牱寮忥紝瀵硅薄褰㈠紡 + * @property {Object} body-style 涓讳綋鑷畾涔夋牱寮忥紝瀵硅薄褰㈠紡 + * @property {String} hover-class 鏍峰紡绫诲悕锛屾寜涓嬫椂鏈夋晥锛堥粯璁-hover-class锛� + * @event {Function} change 褰撳墠婵�娲婚潰鏉垮睍寮�鏃惰Е鍙�(濡傛灉鏄墜椋庣惔妯″紡锛屽弬鏁癮ctiveNames绫诲瀷涓篠tring锛屽惁鍒欎负Array) + * @example <u-collapse></u-collapse> + */ + export default { + name:"u-collapse", + props: { + // 鏄惁鎵嬮鐞存ā寮� + accordion: { + type: Boolean, + default: true + }, + // 澶撮儴鐨勬牱寮� + headStyle: { + type: Object, + default () { + return {} + } + }, + // 涓讳綋鐨勬牱寮� + bodyStyle: { + type: Object, + default () { + return {} + } + }, + // 姣忎竴涓猧tem鐨勬牱寮� + itemStyle: { + type: Object, + default () { + return {} + } + }, + // 鏄惁鏄剧ず鍙充晶鐨勭澶� + arrow: { + type: Boolean, + default: true + }, + // 绠ご鐨勯鑹� + arrowColor: { + type: String, + default: '#909399' + }, + // 鏍囬閮ㄥ垎鎸夊帇鏃剁殑鏍峰紡绫伙紝"none"涓烘棤鏁堟灉 + hoverClass: { + type: String, + default: 'u-hover-class' + } + }, + created() { + this.childrens = [] + }, + data() { + return { + + } + }, + methods: { + // 閲嶆柊鍒濆鍖栦竴娆″唴閮ㄧ殑鎵�鏈夊瓙鍏冪礌鐨勯珮搴﹁绠楋紝鐢ㄤ簬寮傛鑾峰彇鏁版嵁娓叉煋鐨勬儏鍐� + init() { + this.childrens.forEach((vm, index) => { + vm.init(); + }) + }, + // collapse item琚偣鍑伙紝鐢眂ollapse item璋冪敤鐖剁粍浠舵柟娉� + onChange() { + let activeItem = []; + this.childrens.forEach((vm, index) => { + if (vm.isShow) { + activeItem.push(vm.nameSync); + } + }) + // 濡傛灉鏄墜椋庣惔妯″紡锛屽彧鏈変竴涓尮閰嶇粨鏋滐紝涔熷嵆activeItem闀垮害涓�1锛屽皢鍏惰浆涓哄瓧绗︿覆 + if (this.accordion) activeItem = activeItem.join(''); + this.$emit('change', activeItem); + } + } + } +</script> + +<style lang="scss" scoped> + @import "../../libs/css/style.components.scss"; +</style> -- Gitblit v1.9.3