提交 04815006 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

refactor: 限制兼容组件 emit 传递值的测试平台,补充相关注释

上级 a1a7ffe9
<template> <template>
<view> <view>
<call-easy-method-uni-modules ref="callEasyMethod1"></call-easy-method-uni-modules> <call-easy-method-uni-modules ref="callEasyMethod1"></call-easy-method-uni-modules>
<!-- #ifdef APP --> <!-- #ifdef APP-ANDROID || APP-IOS -->
<!-- 在兼容组件中 ios 返回非普通对象数据,比如 Map 数据时候会被 jscore 统一处理为 object,和安卓产生了差异 -->
<!-- 测试用例用来验证返回数据特殊,安卓和其他平台无此限制 -->
<view>---</view> <view>---</view>
<test-props id="btn1" :numList="numList" :objList='objList' @buttonclick='onButtonClick' <test-props id="btn1" :numList="numList" :objList='objList' @buttonclick='onButtonClick'
@numListChange='numListChange' @objListChange='objListChange' @numListChange='numListChange' @objListChange='objListChange'
...@@ -22,7 +24,7 @@ ...@@ -22,7 +24,7 @@
import { testInOtherFile } from './call-method-easycom-uni-modules' import { testInOtherFile } from './call-method-easycom-uni-modules'
import { ref, isProxy, isRef } from 'vue' import { ref, isProxy, isRef } from 'vue'
// #ifdef APP // #ifdef APP-ANDROID || APP-IOS
import { PropsChangeEvent } from '@/uni_modules/test-props' import { PropsChangeEvent } from '@/uni_modules/test-props'
// #endif // #endif
...@@ -86,7 +88,6 @@ ...@@ -86,7 +88,6 @@
const value = res['detail']!['value'] as number[] const value = res['detail']!['value'] as number[]
const isArray = Array.isArray(value) const isArray = Array.isArray(value)
const isLengthGt0 = value.length > 0 const isLengthGt0 = value.length > 0
console.log('is array',isArray,'is length>0',isLengthGt0,'res',isArray && isLengthGt0);
isNumListValid.value = isArray && isLengthGt0 isNumListValid.value = isArray && isLengthGt0
} }
// #endif // #endif
...@@ -106,7 +107,6 @@ ...@@ -106,7 +107,6 @@
const value = res['detail']!['value'] as any[] const value = res['detail']!['value'] as any[]
const isArray = Array.isArray(value) const isArray = Array.isArray(value)
const isLengthGt0 = value.length > 0 const isLengthGt0 = value.length > 0
console.log('is array',isArray,'is length>0',isLengthGt0,'res',isArray && isLengthGt0);
isObjListValid.value = isArray && isLengthGt0 isObjListValid.value = isArray && isLengthGt0
} }
// #endif // #endif
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<view> <view>
<call-easy-method-uni-modules ref="callEasyMethod1"></call-easy-method-uni-modules> <call-easy-method-uni-modules ref="callEasyMethod1"></call-easy-method-uni-modules>
<!-- #ifdef APP --> <!-- #ifdef APP-IOS || APP-ANDROID -->
<!-- 在兼容组件中 ios 返回非普通对象数据,比如 Map 数据时候会被 jscore 统一处理为 object,和安卓产生了差异 -->
<!-- 测试用例用来验证返回数据特殊,安卓和其他平台无此限制 -->
<view>---</view> <view>---</view>
<test-props id="btn1" :numList="numList" :objList='objList' @buttonclick='onButtonClick' <test-props id="btn1" :numList="numList" :objList='objList' @buttonclick='onButtonClick'
@numListChange='numListChange' @objListChange='objListChange' @numListChange='numListChange' @objListChange='objListChange'
...@@ -93,43 +95,43 @@ ...@@ -93,43 +95,43 @@
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
numListChange(res : Map<string, Map<string, any>>) { numListChange(res : Map<string, Map<string, any>>) {
const value = res['detail']!['value'] as number[] const value = res['detail']!['value'] as number[]
const isArray = Array.isArray(value) const isArray = Array.isArray(value)
const isLengthGt0 = value.length > 0 const isLengthGt0 = value.length > 0
this.isNumListValid = isArray && isLengthGt0 this.isNumListValid = isArray && isLengthGt0
}, },
// #endif // #endif
// #ifdef APP-IOS // #ifdef APP-IOS
numListChange(res : any) { numListChange(res : any) {
const value = res['detail']!['value'] as number[] const value = res['detail']!['value'] as number[]
const isArray = Array.isArray(value) const isArray = Array.isArray(value)
const isLengthGt0 = value.length > 0 const isLengthGt0 = value.length > 0
this.isNumListValid = isArray && isLengthGt0 this.isNumListValid = isArray && isLengthGt0
}, },
// #endif // #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
objListChange(res : Map<string, Map<string, any>>) { objListChange(res : Map<string, Map<string, any>>) {
const value = res['detail']!['value'] as number[] const value = res['detail']!['value'] as number[]
const isArray = Array.isArray(value) const isArray = Array.isArray(value)
const isLengthGt0 = value.length > 0 const isLengthGt0 = value.length > 0
this.isObjListValid = isArray && isLengthGt0 this.isObjListValid = isArray && isLengthGt0
}, },
// #endif // #endif
// #ifdef APP-IOS // #ifdef APP-IOS
objListChange(res : any) { objListChange(res : any) {
const value = res['detail']!['value'] as number[] const value = res['detail']!['value'] as number[]
const isArray = Array.isArray(value) const isArray = Array.isArray(value)
const isLengthGt0 = value.length > 0 const isLengthGt0 = value.length > 0
this.isObjListValid = isArray && isLengthGt0 this.isObjListValid = isArray && isLengthGt0
}, },
// #endif // #endif
onButtonClick() { onButtonClick() {
// 改变 props: 观察 props 返回值为非响应式值 // 改变 props: 观察 props 返回值为非响应式值
console.log('button click'); console.log('button click');
this.numList = [3, 2, 1] this.numList = [3, 2, 1]
this.objList = [{ id: '3' }, { id: '4' }] this.objList = [{ id: '3' }, { id: '4' }]
} }
} }
} }
</script> </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册