From f4991944d13b94355fb8aaf03dad7d60ca530ee9 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Thu, 30 Nov 2023 16:36:45 +0800 Subject: [PATCH] fix:是否修改 --- uni_modules/uview-ui/components/u-collapse/u-collapse.vue | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 90 insertions(+), 0 deletions(-) diff --git a/uni_modules/uview-ui/components/u-collapse/u-collapse.vue b/uni_modules/uview-ui/components/u-collapse/u-collapse.vue new file mode 100644 index 0000000..fc188a2 --- /dev/null +++ b/uni_modules/uview-ui/components/u-collapse/u-collapse.vue @@ -0,0 +1,90 @@ +<template> + <view class="u-collapse"> + <u-line v-if="border"></u-line> + <slot /> + </view> +</template> + +<script> + import props from './props.js'; + /** + * collapse ������������ + * @description ������������������������������������ + * @tutorial https://www.uviewui.com/components/collapse.html + * @property {String | Number | Array} value ���������������������name������������������������[<string | number>]���������������������string | number + * @property {Boolean} accordion ������������������������ ������ false ��� + * @property {Boolean} border ��������������������� ( ������ true ��� + * @event {Function} change ���������������������������������(���������������������������������activeNames���������String������������Array) + * @example <u-collapse></u-collapse> + */ + export default { + name: "u-collapse", + mixins: [uni.$u.mpMixin, uni.$u.mixin,props], + watch: { + needInit() { + this.init() + } + }, + created() { + this.children = [] + }, + computed: { + needInit() { + // ������computed���������������accordion���value������������ + // ���������watch���������init()������������������������������������ + return [this.accordion, this.value] + } + }, + watch: { + // ��������������������������������������������������������������������������������������� + parentData() { + if (this.children.length) { + this.children.map(child => { + // ���������������(u-checkbox)���������updateParentData���������������������������(������������������������������������������������������������������) + typeof(child.updateParentData) === 'function' && child.updateParentData() + }) + } + }, + }, + methods: { + // ��������������������������������������������� + init() { + this.children.map(child => { + child.init() + }) + }, + /** + * collapse-item������������������������collapse��������������������������������� + * @param {Object} target ��������������������������� + */ + onChange(target) { + let changeArr = [] + this.children.map((child, index) => { + // ������������������������������������������������������������ + if (this.accordion) { + child.expanded = child === target ? !target.expanded : false + child.setContentAnimate() + } else { + if(child === target) { + child.expanded = !child.expanded + child.setContentAnimate() + } + } + // ������change��������������������������������� + changeArr.push({ + // ������������������name���������������������������������index������ + name: child.name || index, + status: child.expanded ? 'open' : 'close' + }) + }) + + this.$emit('change', changeArr) + this.$emit(target.expanded ? 'open' : 'close', target.name) + } + } + } +</script> + +<style lang="scss" scoped> + @import "../../libs/css/components.scss"; +</style> -- Gitblit v1.8.0