From 2a022b477e99afca3933e6eb23f4ec64b5bcf257 Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Tue, 2 Jan 2024 19:54:37 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=A6=96=E9=A1=B5=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../uni-collapse-item/uni-collapse-item.vue | 138 ++++++++++++++++++
components/uni-collapse-item/util.uts | 19 +++
components/uni-collapse/uni-collapse.vue | 48 ++++++
pages/index.uvue | 114 +++++++--------
4 files changed, 256 insertions(+), 63 deletions(-)
create mode 100644 components/uni-collapse-item/uni-collapse-item.vue
create mode 100644 components/uni-collapse-item/util.uts
create mode 100644 components/uni-collapse/uni-collapse.vue
diff --git a/components/uni-collapse-item/uni-collapse-item.vue b/components/uni-collapse-item/uni-collapse-item.vue
new file mode 100644
index 0000000..84ab91b
--- /dev/null
+++ b/components/uni-collapse-item/uni-collapse-item.vue
@@ -0,0 +1,138 @@
+
+
+
+ {{title}}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/uni-collapse-item/util.uts b/components/uni-collapse-item/util.uts
new file mode 100644
index 0000000..97b7350
--- /dev/null
+++ b/components/uni-collapse-item/util.uts
@@ -0,0 +1,19 @@
+// 查找父组件实例
+export function $dispatch(
+ context : ComponentPublicInstance,
+ componentName : string,
+ eventName : string,
+ ...params : any[]
+) {
+ let parent = context.$parent
+ let name = parent?.$options?.name
+ while (parent != null && (name == null || componentName != name)) {
+ parent = parent.$parent
+ if (parent != null) {
+ name = parent.$options.name
+ }
+ }
+ if (parent != null) {
+ parent.$callMethod(eventName, ...params)
+ }
+}
diff --git a/components/uni-collapse/uni-collapse.vue b/components/uni-collapse/uni-collapse.vue
new file mode 100644
index 0000000..672a78d
--- /dev/null
+++ b/components/uni-collapse/uni-collapse.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/index.uvue b/pages/index.uvue
index 7e93dfd..b8c9096 100644
--- a/pages/index.uvue
+++ b/pages/index.uvue
@@ -1,30 +1,22 @@
-
+
-
-
- {{ item.name }}
-
-
-
-
- {{ page.name }}
-
-
-
-
+
+
+
+
+ {{ page.name }}
+
+
+
+
+
-
+
@@ -61,25 +53,25 @@
url: 'index',
enable: true,
},
- {
- name: 'globalProperties',
- url: 'globalProperties',
- enable: true,
- },
+ {
+ name: 'globalProperties',
+ url: 'globalProperties',
+ enable: true,
+ },
+ ] as PageItem[],
+ },
+ {
+ id: 'built-in-component',
+ name: '内置组件',
+ open: false,
+ pages: [
+ {
+ name: 'keepAlive',
+ url: 'keep-alive',
+ enable: true,
+ },
] as PageItem[],
},
- {
- id: 'built-in-component',
- name: '内置组件',
- open: false,
- pages: [
- {
- name: 'keepAlive',
- url: 'keep-alive',
- enable: true,
- },
- ] as PageItem[],
- },
{
id: 'lifecycle',
name: '生命周期',
@@ -425,11 +417,11 @@
url: 'extends',
enable: false,
},
- {
- name: 'setup',
- url: 'setup',
- enable: true,
- }
+ {
+ name: 'setup',
+ url: 'setup',
+ enable: true,
+ }
] as PageItem[],
},
{
@@ -441,7 +433,7 @@
name: '嵌套组件通信',
url: 'nested-component-communication',
enable: true,
- },{
+ }, {
name: '自定义组件中使用 class 定制另一个自定义组件根节点样式',
url: 'set-custom-child-component-root-node-class',
enable: true,
@@ -487,22 +479,18 @@
+ .down_arrow {
+ width: 8px;
+ height: 8px;
+ transform: rotate(45deg);
+ border-right: 1px #999 solid;
+ border-bottom: 1px #999 solid;
+ margin-top: -3px;
+ transition-property: transform;
+ transition-duration: 0.2s;
+ }
+
\ No newline at end of file
--
GitLab