diff --git a/pages/component-instance/methods/call-method-easycom-uni-modules-composition.test.js b/pages/component-instance/methods/call-method-easycom-uni-modules-composition.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7543c06fefe12969c48fffbb110656a0c81865b3
--- /dev/null
+++ b/pages/component-instance/methods/call-method-easycom-uni-modules-composition.test.js
@@ -0,0 +1,31 @@
+const PAGE_PATH = "/pages/component-instance/methods/call-method-easycom-uni-modules-composition"
+
+
+
+let page
+beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor('view')
+})
+
+it('callMethodTest', async () => {
+ // a[[]] only issue 8582
+ if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('web')) {
+ expect(1).toBe(1)
+ return
+ }
+
+ const delay = () =>
+ new Promise((resolve, _) => {
+ setTimeout(() => {
+ resolve('')
+ }, 1000)
+ })
+
+ await page.callMethod('onButtonClick')
+ await delay()
+ const resStr1 = await page.$("#isNumListValid")
+ const resStr2 = await page.$("#isObjListValid")
+ expect(await resStr1.text()).toBe(`true`)
+ expect(await resStr2.text()).toBe(`true`)
+})
diff --git a/pages/component-instance/methods/call-method-easycom-uni-modules-composition.uvue b/pages/component-instance/methods/call-method-easycom-uni-modules-composition.uvue
index 18102c51b212ea056064b0fbaf00e774afa77537..77a9128ba1072172166e964ee2e7c83c45362af3 100644
--- a/pages/component-instance/methods/call-method-easycom-uni-modules-composition.uvue
+++ b/pages/component-instance/methods/call-method-easycom-uni-modules-composition.uvue
@@ -1,9 +1,11 @@
+
---
-
+
isNumListValid:
{{isNumListValid}}
@@ -12,12 +14,14 @@
isObjListValid:
{{isObjListValid}}
+
diff --git a/pages/component-instance/methods/call-method-easycom-uni-modules-options.test.js b/pages/component-instance/methods/call-method-easycom-uni-modules-options.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..48e5c3a2432236df0db9419f4fb97118ff4c009f
--- /dev/null
+++ b/pages/component-instance/methods/call-method-easycom-uni-modules-options.test.js
@@ -0,0 +1,30 @@
+const PAGE_PATH = "/pages/component-instance/methods/call-method-easycom-uni-modules-options"
+
+let page
+beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor('view')
+})
+
+it('callMethodTest', async () => {
+
+ // app only issue 8582
+ if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('web')) {
+ expect(1).toBe(1)
+ return
+ }
+
+ const delay = () =>
+ new Promise((resolve, _) => {
+ setTimeout(() => {
+ resolve('')
+ }, 1000)
+ })
+
+ await page.callMethod('onButtonClick')
+ await delay()
+ const resStr1 = await page.$("#isNumListValid")
+ const resStr2 = await page.$("#isObjListValid")
+ expect(await resStr1.text()).toBe(`true`)
+ expect(await resStr2.text()).toBe(`true`)
+})
diff --git a/pages/component-instance/methods/call-method-easycom-uni-modules-options.uvue b/pages/component-instance/methods/call-method-easycom-uni-modules-options.uvue
index 84e8eae3e8df697cab42af5b7e67b040b7c62cfc..7544cc6f95f8cc63e38fb63a004d8ee0fdc0d6ba 100644
--- a/pages/component-instance/methods/call-method-easycom-uni-modules-options.uvue
+++ b/pages/component-instance/methods/call-method-easycom-uni-modules-options.uvue
@@ -1,9 +1,12 @@
+
+
---
-
+
isNumListValid:
{{isNumListValid}}
@@ -12,6 +15,7 @@
isObjListValid:
{{isObjListValid}}
+
@@ -33,7 +37,7 @@
isWatched: false,
changeTimes: 0,
numList: [1] as number[], // 传递 props
- objList: [] as Array<{ id : string }>,
+ objList: [] as any[],
isNumListValid: false,
isObjListValid: false
}
@@ -55,10 +59,7 @@
this.callMethod4()
await delay()
this.callMethod5()
- await delay()
- // 改变 props: 观察 props 返回值为非响应式值
- this.numList = [3, 2, 1]
- this.objList = [{ id: '3' }, { id: '4' }]
+
},
callMethod1() {
// 调用组件的 foo1 方法
@@ -91,14 +92,45 @@
return testInOtherFile(this.callEasyMethod1!, text)
},
- numListChange(res) {
- this.isNumListValid = res.detail
- },
- objListChange(res) {
- this.isObjListValid = res.detail
- },
- onButtonClick() {
- }
+ // #ifdef APP-ANDROID
+ numListChange(res : Map>) {
+ const value = res['detail']!['value'] as number[]
+ const isArray = Array.isArray(value)
+ const isLengthGt0 = value.length > 0
+ this.isNumListValid = isArray && isLengthGt0
+ },
+ // #endif
+ // #ifdef APP-IOS
+ numListChange(res : any) {
+ const value = res['detail']!['value'] as number[]
+ const isArray = Array.isArray(value)
+ const isLengthGt0 = value.length > 0
+ this.isNumListValid = isArray && isLengthGt0
+ },
+ // #endif
+
+ // #ifdef APP-ANDROID
+ objListChange(res : Map>) {
+ const value = res['detail']!['value'] as number[]
+ const isArray = Array.isArray(value)
+ const isLengthGt0 = value.length > 0
+ this.isObjListValid = isArray && isLengthGt0
+ },
+ // #endif
+ // #ifdef APP-IOS
+ objListChange(res : any) {
+ const value = res['detail']!['value'] as number[]
+ const isArray = Array.isArray(value)
+ const isLengthGt0 = value.length > 0
+ this.isObjListValid = isArray && isLengthGt0
+ },
+ // #endif
+ onButtonClick() {
+ // 改变 props: 观察 props 返回值为非响应式值
+ console.log('button click');
+ this.numList = [3, 2, 1]
+ this.objList = [{ id: '3' }, { id: '4' }]
+ }
}
}
diff --git a/uni_modules/test-props/utssdk/app-android/event.uts b/uni_modules/test-props/utssdk/app-android/event.uts
new file mode 100644
index 0000000000000000000000000000000000000000..ce2c4e90b88611782028afadeca7956a0861a633
--- /dev/null
+++ b/uni_modules/test-props/utssdk/app-android/event.uts
@@ -0,0 +1,7 @@
+
+import { PropsChangeEvent, PropsChangeEventDetail } from './index.uts'
+export class PropChangeEventImpl extends UniCustomEvent implements PropsChangeEvent {
+ constructor(detail : PropsChangeEventDetail) {
+ super("propChange", detail);
+ }
+}
diff --git a/uni_modules/test-props/utssdk/app-android/index.uts b/uni_modules/test-props/utssdk/app-android/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..c691d41b9e20f1a7a81e87673282b34bb461ff31
--- /dev/null
+++ b/uni_modules/test-props/utssdk/app-android/index.uts
@@ -0,0 +1,4 @@
+import { IPropsChangeEvent,IPropsChangeEventDetail } from '../interface.uts'
+
+export type PropsChangeEvent = IPropsChangeEvent
+export type PropsChangeEventDetail = IPropsChangeEventDetail
diff --git a/uni_modules/test-props/utssdk/app-android/index.vue b/uni_modules/test-props/utssdk/app-android/index.vue
index a178b629a8f2ccf1e7d2a95e9f4e451edf86a349..689d64cc3368154e24fcee8466b66fd09047d8da 100644
--- a/uni_modules/test-props/utssdk/app-android/index.vue
+++ b/uni_modules/test-props/utssdk/app-android/index.vue
@@ -11,7 +11,8 @@
import TextUtils from 'android.text.TextUtils';
import Button from 'android.widget.Button';
import View from 'android.view.View';
-
+ import { IObjItem ,IPropsChangeEvent} from '../interface.uts'
+import {PropChangeEventImpl} from './event.uts'
/**
* 引入三方库
* [可选实现,按需引入]
@@ -33,11 +34,11 @@
/**
* 组件名称,也就是开发者使用的标签
*/
- name: "uts-button",
+ name: "test-props",
/**
* 组件涉及的事件声明,只有声明过的事件,才能被正常发送
*/
- emits: ['buttonclick'],
+ emits: ['buttonclick', 'numListChange', 'objListChange'],
/**
* 属性声明,组件的使用者会传递这些属性值到组件
*/
@@ -45,6 +46,14 @@
"buttontext": {
type: String,
default: "点击触发"
+ },
+ numList: {
+ type: Array as PropType,
+ default: () => [] as number[]
+ },
+ objList: {
+ type: Array as PropType,
+ default: () => [] as IObjItem[]
}
},
/**
@@ -68,6 +77,30 @@
},
immediate: false // 创建时是否通过此方法更新属性,默认值为false
},
+ numList: {
+ handler(newVal : number[], oldVal : number[]) {
+ let detail = new Map()
+ detail.set("value", newVal)
+ let data = new Map()
+ data.set("detail", detail)
+
+ // const event = new PropChangeEventImpl(newVal)
+
+ this.$emit('numListChange', data)
+
+ },
+ immediate: true
+ },
+ objList: {
+ handler(newVal : any[], oldVal : any[]) {
+ let detail = new Map()
+ detail.set("value", newVal)
+ let data = new Map()
+ data.set("detail", detail)
+ this.$emit('objListChange', data)
+ },
+ immediate: true
+ }
},
/**
* 规则:如果没有配置expose,则methods中的方法均对外暴露,如果配置了expose,则以expose的配置为准向外暴露
@@ -192,4 +225,4 @@
\ No newline at end of file
+
diff --git a/uni_modules/test-props/utssdk/app-ios/index.vue b/uni_modules/test-props/utssdk/app-ios/index.vue
index ac76827880e80a0a776ede684b4d03fe33fd53e1..93d97e2561d78f9bef8b3a87c6ca21e36f95810c 100644
--- a/uni_modules/test-props/utssdk/app-ios/index.vue
+++ b/uni_modules/test-props/utssdk/app-ios/index.vue
@@ -86,25 +86,20 @@
},
numList: {
handler(newVal : number[], oldVal : number[]) {
- const isNumber = (val : number) : boolean => typeof val == 'number'
- const isEveryNumber = (newVal as number[]).every(isNumber)
- const isRawType = Array.isArray(newVal) && isEveryNumber
+ let detail = new Map()
+ detail.set("value", newVal)
let data = new Map()
- data.set("detail", isRawType)
+ data.set("detail", detail)
this.$emit('numListChange', data)
-
},
immediate: true
},
objList: {
- handler(newVal:any[], oldVal:any[]) {
-
- const isObj = (item:any):boolean => item instanceof UTSJSONObject
- const isEveryObj = (newVal as any[]).every(isObj)
- const isRawType = Array.isArray(newVal) && isEveryObj
+ handler(newVal : any[], oldVal : any[]) {
+ let detail = new Map()
+ detail.set("value", newVal)
let data = new Map()
- data.set("detail", isRawType)
- console.log(111,newVal,isEveryObj,isRawType)
+ data.set("detail", detail)
this.$emit('objListChange', data)
},
immediate: true
diff --git a/uni_modules/test-props/utssdk/interface.uts b/uni_modules/test-props/utssdk/interface.uts
index bbf3f12bc6733bc511dad01b8cdfbf885d374037..53c33cca7f139101bb137eed465d74ad04e1cb90 100644
--- a/uni_modules/test-props/utssdk/interface.uts
+++ b/uni_modules/test-props/utssdk/interface.uts
@@ -1,3 +1,12 @@
export type IObjItem = {
id : string
}
+
+export type IPropsChangeEventDetail = {
+ value : number
+}
+
+export interface IPropsChangeEvent extends UniVideoEvent {
+ detail : IPropsChangeEventDetail[]
+}
+