From c93d4f131d3f9547b882ec88aab7c890f6b342a8 Mon Sep 17 00:00:00 2001
From: fxy060608 <153647646@qq.com>
Date: Thu, 26 Sep 2024 20:24:15 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20=E8=87=AA=E5=AE=9A?=
=?UTF-8?q?=E4=B9=89easycom=E8=A7=84=E5=88=99=E7=BB=84=E4=BB=B6=E7=B1=BB?=
=?UTF-8?q?=E5=9E=8B=E6=B5=8B=E8=AF=95=20#9386?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/custom-call-easy-method.uvue | 19 +++++++++++++++++++
pages.json | 5 +++++
.../call-method-easycom-composition.uvue | 16 +++++++++++++++-
.../methods/call-method-easycom-options.uvue | 16 ++++++++++++++--
.../methods/call-method-easycom.test.js | 4 ++++
5 files changed, 57 insertions(+), 3 deletions(-)
create mode 100644 components/custom-call-easy-method.uvue
diff --git a/components/custom-call-easy-method.uvue b/components/custom-call-easy-method.uvue
new file mode 100644
index 0000000..a61f5ad
--- /dev/null
+++ b/components/custom-call-easy-method.uvue
@@ -0,0 +1,19 @@
+
+ {{result}}
+
+
+
\ No newline at end of file
diff --git a/pages.json b/pages.json
index 08d184b..18f3329 100644
--- a/pages.json
+++ b/pages.json
@@ -902,6 +902,11 @@
"navigationBarBackgroundColor": "#007AFF"
}
},
+ "easycom": {
+ "custom": {
+ "custom-(.*)": "@/components/custom-$1.uvue"
+ }
+ },
"uniIdRouter": {},
"condition": {
"current": 0,
diff --git a/pages/component-instance/methods/call-method-easycom-composition.uvue b/pages/component-instance/methods/call-method-easycom-composition.uvue
index eebe224..deb6207 100644
--- a/pages/component-instance/methods/call-method-easycom-composition.uvue
+++ b/pages/component-instance/methods/call-method-easycom-composition.uvue
@@ -1,11 +1,18 @@
+
\ No newline at end of file
diff --git a/pages/component-instance/methods/call-method-easycom-options.uvue b/pages/component-instance/methods/call-method-easycom-options.uvue
index 0a4d35e..7e407e2 100644
--- a/pages/component-instance/methods/call-method-easycom-options.uvue
+++ b/pages/component-instance/methods/call-method-easycom-options.uvue
@@ -1,6 +1,7 @@
+
@@ -15,16 +16,19 @@ const delay = (): Promise =>
export default {
data() {
return {
- callEasyMethod1: null as CallEasyMethodComponentPublicInstance | null
+ callEasyMethod1: null as CallEasyMethodComponentPublicInstance | null,
+ customCallEasyMethod1: null as CustomCallEasyMethodComponentPublicInstance | null,
}
},
onReady() {
// 通过组件 ref 属性获取组件实例, 组件标签名首字母大写,驼峰+ComponentPublicInstance
this.callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodComponentPublicInstance
+ this.customCallEasyMethod1 = this.$refs['customCallEasyMethod1'] as CustomCallEasyMethodComponentPublicInstance
this.call()
},
methods: {
async call(): Promise {
+ this.callCustomMethod()
this.callMethod1()
await delay()
this.callMethod2()
@@ -61,7 +65,15 @@ export default {
callMethodTest(text: string): string | null {
const result = this.callEasyMethod1?.foo5?.(text) as string
return result
- }
+ },
+ callCustomMethod() {
+ // 调用组件的 foo 方法
+ this.customCallEasyMethod1?.foo?.()
+ },
+ callCustomMethodTest(): string | null {
+ const result = this.customCallEasyMethod1?.foo?.() as string
+ return result
+ },
}
}
\ No newline at end of file
diff --git a/pages/component-instance/methods/call-method-easycom.test.js b/pages/component-instance/methods/call-method-easycom.test.js
index 581f70b..3447b17 100644
--- a/pages/component-instance/methods/call-method-easycom.test.js
+++ b/pages/component-instance/methods/call-method-easycom.test.js
@@ -10,6 +10,8 @@ describe('call-method-easycom', () => {
const title = Date.now() + ''
const result = await page.callMethod('callMethodTest', title)
expect(result).toBe(title)
+ const customResult = await page.callMethod('callCustomMethodTest')
+ expect(customResult).toBe('custom foo')
})
it('callMethodTest Composition API', async () => {
@@ -18,5 +20,7 @@ describe('call-method-easycom', () => {
const title = Date.now() + ''
const result = await page.callMethod('callMethodTest', title)
expect(result).toBe(title)
+ const customResult = await page.callMethod('callCustomMethodTest')
+ expect(customResult).toBe('custom foo')
})
})
--
GitLab