From 52073af884eb0248b5765624a41df43039efb02a Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Thu, 15 Aug 2024 19:02:16 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=20props=20=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8=E5=BC=95=E5=85=A5=E7=B1=BB=E5=9E=8B=E7=A4=BA=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../props/props-composition.uvue | 49 ++++++------
.../props/props-options.uvue | 74 ++++++++++---------
pages/component-instance/props/props.test.js | 30 +++++---
.../props/reference-types-composition.uvue | 19 +++++
.../props/reference-types-options.uvue | 25 +++++++
pages/component-instance/props/types.uts | 8 ++
6 files changed, 139 insertions(+), 66 deletions(-)
create mode 100644 pages/component-instance/props/reference-types-composition.uvue
create mode 100644 pages/component-instance/props/reference-types-options.uvue
create mode 100644 pages/component-instance/props/types.uts
diff --git a/pages/component-instance/props/props-composition.uvue b/pages/component-instance/props/props-composition.uvue
index 5b8c276..236ba8d 100644
--- a/pages/component-instance/props/props-composition.uvue
+++ b/pages/component-instance/props/props-composition.uvue
@@ -1,21 +1,28 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/component-instance/props/props-options.uvue b/pages/component-instance/props/props-options.uvue
index a559b76..1aa0e8e 100644
--- a/pages/component-instance/props/props-options.uvue
+++ b/pages/component-instance/props/props-options.uvue
@@ -1,33 +1,41 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/component-instance/props/props.test.js b/pages/component-instance/props/props.test.js
index 7e453ec..ff65987 100644
--- a/pages/component-instance/props/props.test.js
+++ b/pages/component-instance/props/props.test.js
@@ -1,39 +1,42 @@
const OPTIONS_PAGE_PATH = '/pages/component-instance/props/props-options'
const COMPOSITION_PAGE_PATH = '/pages/component-instance/props/props-composition'
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+const isAndroid = platformInfo.includes('android')
+
describe('props', () => {
let page
const test = async (page) => {
const arrayLiteralStr = await page.$('#array-literal-str')
expect(await arrayLiteralStr.text()).toBe('str')
-
+
const arrayLiteralNum = await page.$('#array-literal-num')
expect(await arrayLiteralNum.text()).toBe('10')
-
+
const arrayLiteralBool = await page.$('#array-literal-bool')
expect(await arrayLiteralBool.text()).toBe('true')
-
+
const arrayLiteralObj = await page.$('#array-literal-obj')
expect(await arrayLiteralObj.text()).toBe('{"age":18}')
-
+
const arrayLiteralArr = await page.$('#array-literal-arr')
expect(await arrayLiteralArr.text()).toBe('["a","b","c"]')
-
+
const objectTypeStr = await page.$('#object-type-str')
expect(await objectTypeStr.text()).toBe('str')
-
+
const objectTypeNum = await page.$('#object-type-num')
expect(await objectTypeNum.text()).toBe('10')
-
+
const objectTypeBool = await page.$('#object-type-bool')
expect(await objectTypeBool.text()).toBe('true')
-
+
const objectTypeObj = await page.$('#object-type-obj')
expect(await objectTypeObj.text()).toBe('{"age":18}')
-
+
const objectTypeArr = await page.$('#object-type-arr')
expect(await objectTypeArr.text()).toBe('["a","b","c"]')
-
+
const sameNamePropDefaultValueArr = await page.$('#same-name-prop-default-value-arr')
expect(await sameNamePropDefaultValueArr.text()).toBe('[1,2,3]')
@@ -41,19 +44,22 @@ describe('props', () => {
expect(await propMsg.text()).toBe('hello')
const propLabels = await page.$('#prop-labels')
expect(await propLabels.text()).toBe('["a","b"]')
+
+ const referenceTypeList = await page.$('#reference-type-list')
+ expect(await referenceTypeList.text()).toBe(isAndroid ? '[1,2,3]' : '["a","b","c"]')
}
it('props 选项式 API', async () => {
page = await program.reLaunch(OPTIONS_PAGE_PATH)
await page.waitFor('view')
-
+
await test(page)
});
it('props 组合式 API', async () => {
page = await program.reLaunch(COMPOSITION_PAGE_PATH)
await page.waitFor('view')
-
+
await test(page)
})
})
\ No newline at end of file
diff --git a/pages/component-instance/props/reference-types-composition.uvue b/pages/component-instance/props/reference-types-composition.uvue
new file mode 100644
index 0000000..0232c79
--- /dev/null
+++ b/pages/component-instance/props/reference-types-composition.uvue
@@ -0,0 +1,19 @@
+
+
+ reference types
+ {{ JSON.stringify(list) }}
+
+
+
\ No newline at end of file
diff --git a/pages/component-instance/props/reference-types-options.uvue b/pages/component-instance/props/reference-types-options.uvue
new file mode 100644
index 0000000..af166c3
--- /dev/null
+++ b/pages/component-instance/props/reference-types-options.uvue
@@ -0,0 +1,25 @@
+
+
+ reference types
+ {{ JSON.stringify(list) }}
+
+
+
\ No newline at end of file
diff --git a/pages/component-instance/props/types.uts b/pages/component-instance/props/types.uts
new file mode 100644
index 0000000..e43f2c9
--- /dev/null
+++ b/pages/component-instance/props/types.uts
@@ -0,0 +1,8 @@
+export type ReferenceTypesProps = {
+ // #ifdef APP-ANDROID
+ list: number[]
+ // #endif
+ // #ifndef APP-ANDROID
+ list: string[]
+ // #endif
+}
--
GitLab