diff --git a/cool/utils/comm.ts b/cool/utils/comm.ts index 0875b6e..1fe1bf7 100644 --- a/cool/utils/comm.ts +++ b/cool/utils/comm.ts @@ -595,6 +595,22 @@ export function base64ToBlob(data: string, type: string = "image/jpeg"): Blob { // #endif } +/** + * 检查两个值是否相等 + * @param a 值1 + * @param b 值2 + * @returns 是否相等 + */ +export function isEqual(a: any, b: any): boolean { + if (isObject(a) && isObject(b)) { + return isEqual(JSON.stringify(a), JSON.stringify(b)); + } else if (isArray(a) && isArray(b)) { + return isEqual(JSON.stringify(a), JSON.stringify(b)); + } + + return a == b; +} + /** * 检查是否为小程序环境 * @returns 是否为小程序环境 diff --git a/cool/utils/parse.ts b/cool/utils/parse.ts index 416a187..74e14f6 100644 --- a/cool/utils/parse.ts +++ b/cool/utils/parse.ts @@ -111,11 +111,11 @@ export const parseClass = (data: any): string => { * @returns 转换后的UTSJSONObject对象 */ export function parseToObject(data: T): UTSJSONObject { - // #ifdef APP + // #ifdef APP-ANDROID return JSON.parseObject(JSON.stringify(data)!)!; // #endif - // #ifndef APP + // #ifndef APP-ANDROID return JSON.parse(JSON.stringify(data)) as UTSJSONObject; // #endif } diff --git a/pages/demo/form/form.uvue b/pages/demo/form/form.uvue index 05b1341..b091521 100644 --- a/pages/demo/form/form.uvue +++ b/pages/demo/form/form.uvue @@ -12,45 +12,93 @@ :disabled="saving" label-position="top" > - - + + - - + + - - + + - - + + + + - - + + + + - + + + {{ item.label }} + + + + + + + + + + + + + + + + + + + + - {{ + {{ JSON.stringify(formData, null, 4) }} @@ -58,13 +106,15 @@ - 重置 + {{ + t("重置") + }} 提交{{ t("提交") }} @@ -72,38 +122,78 @@