consumer模块完成度95%,检查消费者前端bug并修复
This commit is contained in:
@@ -109,35 +109,74 @@
|
||||
|
||||
1. 布局方式
|
||||
- 只支持 display: flex
|
||||
- 不支持 display: grid
|
||||
- 不支持 display: grid、display: block
|
||||
- 不支持 gap
|
||||
- 不支持 table、grid、grid-template-columns
|
||||
|
||||
2. 单位与计算
|
||||
- 不支持 calc()
|
||||
- 不支持的单位: vh
|
||||
- 不支持的单位: vh、vw
|
||||
- property value `100%` is not supported for min-height (supported values are: number|pixel)
|
||||
- property value `60%` is not supported for max-height (supported values are: number|pixel)
|
||||
- property value `calc(33.33% - 10px)` is not supported for min-width
|
||||
- height 不支持 vh 单位,需要使用具体的像素值或百分比
|
||||
|
||||
3. 选择器
|
||||
- [APP-ANDROID] 不支持伪类选择器
|
||||
- [APP-IOS] 不支持伪类选择器
|
||||
- ERROR: Selector `.login-button[disabled]` is not supported. uvue only support classname selector
|
||||
|
||||
4. 其他样式
|
||||
4. font-weight 限制
|
||||
- font-weight 只支持: normal | bold | 400 | 700
|
||||
- 不支持: 100, 300, 500, 600, 900 等其他数值
|
||||
|
||||
5. border-radius 限制
|
||||
- border-radius 不支持百分比单位 (如 50%)
|
||||
- 需要使用具体的像素值 (如 border-radius: 9px 实现圆形)
|
||||
|
||||
6. line-height 限制
|
||||
- line-height 不支持 normal 值
|
||||
- 需要使用具体的数值或像素值 (如 line-height: 36px 或 line-height: 1.5)
|
||||
|
||||
7. position 限制
|
||||
- position 不支持 sticky 值
|
||||
- 只支持: relative | absolute | fixed
|
||||
|
||||
8. 不支持的 CSS 属性
|
||||
- outline 属性不支持
|
||||
- aspect-ratio 属性不支持,需要用具体的 width 和 height 值
|
||||
- text-decoration 属性不支持(如 line-through)
|
||||
- align-items 不支持 baseline 值,只支持 center | flex-start | flex-end | stretch
|
||||
- 不支持后代选择器(如 .parent text),只支持类名选择器
|
||||
|
||||
9. 其他样式
|
||||
- WARNING: `backdrop-filter` is not a standard property name
|
||||
- style property `white-space` is only supported on `<text>|<button>`
|
||||
- ERROR: property value `all` is not supported for `transition-property`
|
||||
|
||||
================================================================================
|
||||
六、scroll-view 使用
|
||||
六、UTS 模板表达式限制
|
||||
================================================================================
|
||||
|
||||
1. 条件语句必须使用布尔类型
|
||||
- 错误码: UTS110111120
|
||||
- 不支持 || 运算符的隐式类型转换
|
||||
- 错误写法: {{ value || '默认值' }}
|
||||
- 正确写法: {{ value != null && value != '' ? value : '默认值' }}
|
||||
|
||||
2. 模板中的类型判断
|
||||
- 所有条件表达式必须返回布尔值
|
||||
- 不能使用 truthy/falsy 值作为条件
|
||||
|
||||
================================================================================
|
||||
七、scroll-view 使用
|
||||
================================================================================
|
||||
|
||||
- scroll-view 在 uni-app-x 中不是用 scroll-y=true
|
||||
- 而是要用 direction="vertical"
|
||||
|
||||
================================================================================
|
||||
七、异步与回调
|
||||
八、异步与回调
|
||||
================================================================================
|
||||
|
||||
- uni.showModal 的 success 回调不能是 async 函数
|
||||
@@ -146,7 +185,7 @@
|
||||
- 解决方案:使用普通函数 function name(): Type {} 代替箭头函数
|
||||
|
||||
================================================================================
|
||||
八、响应式数据
|
||||
九、响应式数据
|
||||
================================================================================
|
||||
|
||||
- 对于需要整体替换的数组,推荐使用 ref 而非 reactive
|
||||
@@ -155,7 +194,7 @@
|
||||
- 对于可能为 null 的参数,需要显式检查后再传递给函数
|
||||
|
||||
================================================================================
|
||||
九、类型导入
|
||||
十、类型导入
|
||||
================================================================================
|
||||
|
||||
- 类型导入需要使用 type 关键字
|
||||
@@ -165,7 +204,7 @@
|
||||
- 返回的是 result,resultdata 一般可以 as Array<T>
|
||||
|
||||
================================================================================
|
||||
十、常见错误速查
|
||||
十一、常见错误速查
|
||||
================================================================================
|
||||
|
||||
1. "Unresolved reference" - 函数未定义或顺序错误
|
||||
@@ -179,7 +218,7 @@
|
||||
9. "参数类型不匹配" - 参数类型错误,需要显式类型转换
|
||||
|
||||
================================================================================
|
||||
十一、简明速记(100+条)
|
||||
十二、简明速记(100+条)
|
||||
================================================================================
|
||||
|
||||
1. 表单优先用 form 组件
|
||||
@@ -197,84 +236,89 @@
|
||||
13. 类型推断严格,必要时用 as Type 明确类型
|
||||
14. 不支持 Intersection Type
|
||||
15. picker 用 picker-view 或 uni.showActionSheet 替代
|
||||
16. 样式只支持 display: flex,不支持 gap、grid、calc()、伪类选择器
|
||||
16. 样式只支持 display: flex,不支持 gap、grid、calc()、伪类选择器、display: block
|
||||
17. scroll-view 用 direction="vertical"
|
||||
18. 不支持 table、grid、vh 单位、min-width: 100% 等
|
||||
19. 组件事件如 picker-view 用 UniPickerViewChangeEvent
|
||||
20. 时间选择用 uni_modules/lime-date-time-picker
|
||||
21. 类型转换建议用 utils/utis 下的 UTSJSONObject
|
||||
22. 在 uts setup 的 android 模式下,调用的函数必须在调用之前定义
|
||||
23. 箭头函数不支持默认参数值,改用显式传参或普通函数定义
|
||||
24. 不支持 Number()、String() 构造函数,用 as 类型转换
|
||||
25. 不支持 Object.keys(),用 JSON.stringify() 或 for 循环
|
||||
26. 不支持 typeof xxx === 'function',用 try-catch 替代
|
||||
27. 不支持 as unknown as 语法
|
||||
28. parseInt() 参数必须是 string 类型
|
||||
29. decodeURIComponent() 返回可空类型,需要处理 null
|
||||
30. charCodeAt() 返回可空类型,需要处理 null
|
||||
31. 不支持内联对象类型,需要在 types 文件中单独定义
|
||||
32. UTSJSONObject.get() 返回可空类型 Any?,需要处理 null 并转换为具体类型
|
||||
33. Array<any> 元素不能直接访问属性,需转换为 UTSJSONObject 或定义明确类型
|
||||
34. 类型定义中属性可能为 null 时,必须声明为可空类型(如 any | null)
|
||||
35. switch 语句在某些版本可能有问题,建议用 if-else 替代
|
||||
36. 模板中可选链 ?.length 需要改为显式判断:v-if="arr != null && arr.length > 0"
|
||||
37. 解构赋值 const { data, error } 在 UTS 中可能有问题,建议用 response.data 方式访问
|
||||
38. response.data 返回 Any?,赋值前需要判断 null 并类型转换
|
||||
39. 空数组 [] 无法推断类型,需要显式声明:let arr: Array<any> = [] 或先判断 null 再转换
|
||||
40. ref 对象字面量需要定义类型:const obj = ref<MyType>({...} as MyType),否则属性访问会报错
|
||||
41. if 条件必须是 boolean,可空类型要用 != null 判断,if (obj != null) 而非 if (obj)
|
||||
42. throw 语句不能抛出 Any 类型,需要处理错误而非抛出
|
||||
43. 模板中可选链 ?.property 需要改为三元表达式:obj != null ? obj.property : ''
|
||||
44. ref<any> 在模板中无法访问属性,必须定义明确类型,ref<MyType | null>(null)
|
||||
45. 展开运算符 [...arr] 不支持,需要手动复制数组
|
||||
46. Array.from(new Set()) 不支持,需要手动去重
|
||||
47. Promise.all 可能有问题,建议改为顺序执行
|
||||
48. .sort(() => Math.random() - 0.5) 随机排序不支持,需要手动实现
|
||||
49. 数组索引访问 arr[index] 可能越界,建议用 if-else 替代数组查找
|
||||
50. 事件对象 e.detail.value 需要转换为 UTSJSONObject 后访问
|
||||
51. String() 构造函数不支持,用 as string 类型转换
|
||||
52. 数组类型简写 string[] 需要改为 Array<string>
|
||||
53. any 类型参数不能直接访问属性,需要转换为 UTSJSONObject 后使用 get/getString/getNumber 方法
|
||||
54. 模板中 !变量 取反不支持,改为显式判断:v-if="str == ''" 或 v-if="bool == false"
|
||||
55. 模板中 :class="{ 'class': condition }" 对象语法可能有问题,改为三元表达式::class="condition ? 'class' : ''"
|
||||
56. supabase .update() 参数需要 UTSJSONObject 类型,用 new UTSJSONObject() 创建并用 .set() 设置属性
|
||||
57. ref<Array<any>> 在模板中无法访问元素属性,必须定义明确的类型后才能访问
|
||||
58. 函数参数可以用联合类型:func(item: TypeA | TypeB)
|
||||
59. JSON.stringify(UTSJSONObject) 可能有问题,需要手动拼接字符串
|
||||
60. UTSJSONObject.keys() 方法不存在,无法获取键列表
|
||||
61. 联合类型参数不能直接访问属性,需要先类型转换:const id = (item as TypeA).id
|
||||
62. 某些 uni API 可能不存在(如 navigateToMiniProgram),需要检查或替换
|
||||
63. JSON.parse(JSON.stringify(obj)) 复杂转换可能有问题,简化处理
|
||||
64. showModal success 回调不能是 async 函数,需要改为同步或使用 Promise
|
||||
65. supa.auth.signOut() 等 supabase auth 方法可能不支持,需要简化处理
|
||||
66. 模板中可空字符串判断 userInfo.phone ? 改为 userInfo.phone != null && userInfo.phone != ''
|
||||
67. Promise.all() 可能有问题,建议改为顺序执行或 setTimeout
|
||||
68. .then() 回调可能有问题,建议用 async/await 或直接调用
|
||||
69. let res: any = null 不支持,改为 let res: any = {} 或其他默认值
|
||||
70. 类型定义中没有的字段不能赋值,检查类型定义后移除多余字段
|
||||
71. ref<Array<any>> 在模板中无法访问元素属性,必须定义明确的类型
|
||||
72. 模板中复杂表达式如 parseFloat(String(x)) 不支持,简化为直接比较
|
||||
73. forEach 不支持,改用 for 循环
|
||||
74. any 类型数组元素不能直接访问属性,需转换为 UTSJSONObject
|
||||
75. showModal success 回调不能是 async 函数,需要改为同步调用独立 async 函数
|
||||
76. 被生命周期钩子调用的函数必须在钩子之前定义,包括 onMounted、watch、onUnmounted 等
|
||||
77. 箭头函数不支持默认参数值,改用显式传参或普通函数定义
|
||||
78. 对象字面量赋值给 ref<Type> 需要显式类型声明:const obj: Type = {...} as Type
|
||||
79. 模板中访问对象属性时,类型定义必须包含该属性,否则报 "找不到名称" 错误
|
||||
80. !variable 取反操作不支持,改为 variable == '' 或 variable == false
|
||||
81. supa.auth 方法不支持,需要简化处理或移除
|
||||
82. setInterval 回调中使用外部变量,需要先声明:let timer: number = 0,然后在回调中赋值
|
||||
83. $t() 国际化函数在模板中可能有问题,建议使用硬编码文本或自定义翻译函数
|
||||
84. profile.username ?? $t('xxx') 混合表达式不支持,改为条件判断:profile != null && profile.username != null ? profile.username : '默认值'
|
||||
85. 可选链操作符 ?. 在某些场景不支持,如 currentPage?.options,需要改为 if 判断
|
||||
86. as any[] 类型转换后无法访问属性,需要使用正确的类型如 UTSJSONObject
|
||||
87. 可空类型 string | null 传给需要 string 的函数,需要显式类型转换:redirect as string
|
||||
88. setInterval 回调中修改外部变量,需要用 ref 而不是 let 声明变量,避免 smart cast 问题
|
||||
89. 非空断言操作符 ! 在某些场景仍无法解决类型问题,建议简化逻辑避免复杂类型转换
|
||||
90. decodeURIComponent 函数参数类型严格,可空类型即便使用 ! 也可能报错,建议简化或避免使用
|
||||
91. getCurrentPages() 获取页面 options 复杂且容易出错,建议简化跳转逻辑
|
||||
92. 模板中内联箭头函数不支持类型注解,如 @input="(e: any) => ..." 会报错,改用 v-model
|
||||
93. :class="{ disabled: codeDisabled }" 对象语法可能有问题,改为三元表达式 :class="codeDisabled ? 'disabled' : ''"
|
||||
18. 不支持 table、grid、vh/vw 单位、min-height/max-height 百分比等
|
||||
19. font-weight 只支持 normal/bold/400/700,不支持 300/500/600 等数值
|
||||
20. border-radius 不支持百分比(50%),用具体像素值(9px)实现圆形
|
||||
21. line-height 不支持 normal,用具体数值(36px)或倍数(1.5)
|
||||
22. position 不支持 sticky,只支持 relative/absolute/fixed
|
||||
23. 不支持 outline、aspect-ratio、text-decoration 等 CSS 属性
|
||||
24. align-items 不支持 baseline,只支持 center/flex-start/flex-end/stretch
|
||||
25. 组件事件如 picker-view 用 UniPickerViewChangeEvent
|
||||
26. 时间选择用 uni_modules/lime-date-time-picker
|
||||
27. 类型转换建议用 utils/utis 下的 UTSJSONObject
|
||||
28. 在 uts setup 的 android 模式下,调用的函数必须在调用之前定义
|
||||
29. 箭头函数不支持默认参数值,改用显式传参或普通函数定义
|
||||
30. 不支持 Number()、String() 构造函数,用 as 类型转换
|
||||
31. 不支持 Object.keys(),用 JSON.stringify() 或 for 循环
|
||||
32. 不支持 typeof xxx === 'function',用 try-catch 替代
|
||||
33. 不支持 as unknown as 语法
|
||||
34. parseInt() 参数必须是 string 类型
|
||||
35. decodeURIComponent() 返回可空类型,需要处理 null
|
||||
36. charCodeAt() 返回可空类型,需要处理 null
|
||||
37. 不支持内联对象类型,需要在 types 文件中单独定义
|
||||
38. UTSJSONObject.get() 返回可空类型 Any?,需要处理 null 并转换为具体类型
|
||||
39. Array<any> 元素不能直接访问属性,需转换为 UTSJSONObject 或定义明确类型
|
||||
40. 类型定义中属性可能为 null 时,必须声明为可空类型(如 any | null)
|
||||
41. switch 语句在某些版本可能有问题,建议用 if-else 替代
|
||||
42. 模板中可选链 ?.length 需要改为显式判断:v-if="arr != null && arr.length > 0"
|
||||
43. 解构赋值 const { data, error } 在 UTS 中可能有问题,建议用 response.data 方式访问
|
||||
44. response.data 返回 Any?,赋值前需要判断 null 并类型转换
|
||||
45. 空数组 [] 无法推断类型,需要显式声明:let arr: Array<any> = [] 或先判断 null 再转换
|
||||
46. ref 对象字面量需要定义类型:const obj = ref<MyType>({...} as MyType),否则属性访问会报错
|
||||
47. if 条件必须是 boolean,可空类型要用 != null 判断,if (obj != null) 而非 if (obj)
|
||||
48. throw 语句不能抛出 Any 类型,需要处理错误而非抛出
|
||||
49. 模板中可选链 ?.property 需要改为三元表达式:obj != null ? obj.property : ''
|
||||
50. ref<any> 在模板中无法访问属性,必须定义明确类型,ref<MyType | null>(null)
|
||||
51. 展开运算符 [...arr] 不支持,需要手动复制数组
|
||||
52. Array.from(new Set()) 不支持,需要手动去重
|
||||
53. Promise.all 可能有问题,建议改为顺序执行
|
||||
54. .sort(() => Math.random() - 0.5) 随机排序不支持,需要手动实现
|
||||
55. 数组索引访问 arr[index] 可能越界,建议用 if-else 替代数组查找
|
||||
56. 事件对象 e.detail.value 需要转换为 UTSJSONObject 后访问
|
||||
57. String() 构造函数不支持,用 as string 类型转换
|
||||
58. 数组类型简写 string[] 需要改为 Array<string>
|
||||
59. any 类型参数不能直接访问属性,需要转换为 UTSJSONObject 后使用 get/getString/getNumber 方法
|
||||
60. 模板中 !变量 取反不支持,改为显式判断:v-if="str == ''" 或 v-if="bool == false"
|
||||
61. 模板中 :class="{ 'class': condition }" 对象语法可能有问题,改为三元表达式::class="condition ? 'class' : ''"
|
||||
62. supabase .update() 参数需要 UTSJSONObject 类型,用 new UTSJSONObject() 创建并用 .set() 设置属性
|
||||
63. ref<Array<any>> 在模板中无法访问元素属性,必须定义明确的类型后才能访问
|
||||
64. 函数参数可以用联合类型:func(item: TypeA | TypeB)
|
||||
65. JSON.stringify(UTSJSONObject) 可能有问题,需要手动拼接字符串
|
||||
66. UTSJSONObject.keys() 方法不存在,无法获取键列表
|
||||
67. 联合类型参数不能直接访问属性,需要先类型转换:const id = (item as TypeA).id
|
||||
68. 某些 uni API 可能不存在(如 navigateToMiniProgram),需要检查或替换
|
||||
69. JSON.parse(JSON.stringify(obj)) 复杂转换可能有问题,简化处理
|
||||
69. showModal success 回调不能是 async 函数,需要改为同步或使用 Promise
|
||||
70. supa.auth.signOut() 等 supabase auth 方法可能不支持,需要简化处理
|
||||
71. 模板中可空字符串判断 userInfo.phone ? 改为 userInfo.phone != null && userInfo.phone != ''
|
||||
72. .then() 回调可能有问题,建议用 async/await 或直接调用
|
||||
73. let res: any = null 不支持,改为 let res: any = {} 或其他默认值
|
||||
74. 类型定义中没有的字段不能赋值,检查类型定义后移除多余字段
|
||||
75. ref<Array<any>> 在模板中无法访问元素属性,必须定义明确的类型
|
||||
76. 模板中复杂表达式如 parseFloat(String(x)) 不支持,简化为直接比较
|
||||
77. forEach 不支持,改用 for 循环
|
||||
78. any 类型数组元素不能直接访问属性,需转换为 UTSJSONObject
|
||||
79. showModal success 回调不能是 async 函数,需要改为同步调用独立 async 函数
|
||||
80. 被生命周期钩子调用的函数必须在钩子之前定义,包括 onMounted、watch、onUnmounted 等
|
||||
81. 箭头函数不支持默认参数值,改用显式传参或普通函数定义
|
||||
82. 对象字面量赋值给 ref<Type> 需要显式类型声明:const obj: Type = {...} as Type
|
||||
83. 模板中访问对象属性时,类型定义必须包含该属性,否则报 "找不到名称" 错误
|
||||
84. !variable 取反操作不支持,改为 variable == '' 或 variable == false
|
||||
85. supa.auth 方法不支持,需要简化处理或移除
|
||||
86. setInterval 回调中使用外部变量,需要先声明:let timer: number = 0,然后在回调中赋值
|
||||
87. $t() 国际化函数在模板中可能有问题,建议使用硬编码文本或自定义翻译函数
|
||||
88. profile.username ?? $t('xxx') 混合表达式不支持,改为条件判断:profile != null && profile.username != null ? profile.username : '默认值'
|
||||
89. 可选链操作符 ?. 在某些场景不支持,如 currentPage?.options,需要改为 if 判断
|
||||
90. as any[] 类型转换后无法访问属性,需要使用正确的类型如 UTSJSONObject
|
||||
91. 可空类型 string | null 传给需要 string 的函数,需要显式类型转换:redirect as string
|
||||
92. setInterval 回调中修改外部变量,需要用 ref 而不是 let 声明变量,避免 smart cast 问题
|
||||
93. 非空断言操作符 ! 在某些场景仍无法解决类型问题,建议简化逻辑避免复杂类型转换
|
||||
94. decodeURIComponent 函数参数类型严格,可空类型即便使用 ! 也可能报错,建议简化或避免使用
|
||||
95. getCurrentPages() 获取页面 options 复杂且容易出错,建议简化跳转逻辑
|
||||
96. 模板中内联箭头函数不支持类型注解,如 @input="(e: any) => ..." 会报错,改用 v-model
|
||||
97. :class="{ disabled: codeDisabled }" 对象语法可能有问题,改为三元表达式 :class="codeDisabled ? 'disabled' : ''"
|
||||
94. 使用外部类型定义时,确保所有属性都有默认值,避免 null 导致类型不匹配
|
||||
95. Supabase insert/update 在 .uvue 文件中直接调用可能报类型错误,建议封装到 .uts 服务文件中调用
|
||||
96. 可空类型属性在模板中使用时需要处理 null:profile.gender ?? 'other'
|
||||
@@ -289,7 +333,7 @@
|
||||
105. 使用辅助函数 safeGetString、safeGetNumber 处理数据库字段
|
||||
|
||||
================================================================================
|
||||
十二、构造函数限制
|
||||
十三、构造函数限制
|
||||
================================================================================
|
||||
|
||||
1. 不支持 Number() 构造函数,使用 as number 类型转换
|
||||
@@ -297,7 +341,7 @@
|
||||
3. 示例:Number(x) → x as number,String(i) → i as string
|
||||
|
||||
================================================================================
|
||||
十三、取反操作符限制
|
||||
十四、取反操作符限制
|
||||
================================================================================
|
||||
|
||||
1. 不支持 !变量 的取反操作符用于判断空
|
||||
@@ -305,7 +349,7 @@
|
||||
3. 示例:!this.selectedSkuId → (this.selectedSkuId == null || this.selectedSkuId === '')
|
||||
|
||||
================================================================================
|
||||
十四、parseInt/parseFloat 限制
|
||||
十五、parseInt/parseFloat 限制
|
||||
================================================================================
|
||||
|
||||
1. parseInt() 参数必须是 string 类型
|
||||
@@ -313,7 +357,7 @@
|
||||
3. 示例:parseInt(this.quantity) 错误,quantity 是 number,直接用 this.quantity
|
||||
|
||||
================================================================================
|
||||
十五、Object.keys() 不支持
|
||||
十六、Object.keys() 不支持
|
||||
================================================================================
|
||||
|
||||
1. 不支持 Object.keys() 方法
|
||||
@@ -321,21 +365,21 @@
|
||||
3. UTSJSONObject 可用 .keys() 方法(但某些版本可能不支持)
|
||||
|
||||
================================================================================
|
||||
十六、typeof 函数检查不支持
|
||||
十七、typeof 函数检查不支持
|
||||
================================================================================
|
||||
|
||||
1. 不支持 typeof xxx === 'function' 语法
|
||||
2. 替代方案:使用 try-catch 包裹方法调用
|
||||
|
||||
================================================================================
|
||||
十七、as unknown as 语法不支持
|
||||
十八、as unknown as 语法不支持
|
||||
================================================================================
|
||||
|
||||
1. 不支持 as unknown as 双重类型转换
|
||||
2. 直接使用 as 目标类型:obj as UTSJSONObject
|
||||
|
||||
================================================================================
|
||||
十八、可空类型方法返回值
|
||||
十九、可空类型方法返回值
|
||||
================================================================================
|
||||
|
||||
1. decodeURIComponent() 返回 String?,需要处理 null
|
||||
@@ -343,7 +387,7 @@
|
||||
3. 示例:const code = str.charCodeAt(i); if (code != null) { ... }
|
||||
|
||||
================================================================================
|
||||
十九、内联对象类型不支持
|
||||
二十、内联对象类型不支持
|
||||
================================================================================
|
||||
|
||||
1. 不支持 Array<{id: string, name: string}> 这种内联类型定义
|
||||
@@ -351,28 +395,28 @@
|
||||
3. 示例:定义 type ItemType = { id: string, name: string },然后使用 Array<ItemType>
|
||||
|
||||
================================================================================
|
||||
二十、eventChannel 不支持
|
||||
二十一、eventChannel 不支持
|
||||
================================================================================
|
||||
|
||||
1. uni.navigateTo 的 success 回调中 res.eventChannel 不支持
|
||||
2. 替代方案:使用 Storage 或全局变量传递数据
|
||||
|
||||
================================================================================
|
||||
二十一、链式调用问题
|
||||
二十二、链式调用问题
|
||||
================================================================================
|
||||
|
||||
1. .map().join() 链式调用可能导致类型推断失败
|
||||
2. 替代方案:使用 for 循环或分步处理
|
||||
|
||||
================================================================================
|
||||
二十二、v-model 类型限制
|
||||
二十三、v-model 类型限制
|
||||
================================================================================
|
||||
|
||||
1. input 的 v-model 期望 string 类型
|
||||
2. 如果变量是 number,使用 :value="variable.toString()" 替代 v-model
|
||||
|
||||
================================================================================
|
||||
二十三、setup 模式函数定义顺序(重要)
|
||||
二十四、setup 模式函数定义顺序(重要)
|
||||
================================================================================
|
||||
|
||||
在 <script setup lang="uts"> 中,函数定义顺序至关重要:
|
||||
@@ -447,7 +491,7 @@
|
||||
- 解决:调整函数定义顺序,确保被调用的函数先定义
|
||||
|
||||
================================================================================
|
||||
二十四、箭头函数限制(重要)
|
||||
二十五、箭头函数限制(重要)
|
||||
================================================================================
|
||||
|
||||
1. 箭头函数不支持默认参数值
|
||||
@@ -475,7 +519,7 @@
|
||||
- 解决:移除默认参数,改用显式传参或普通函数定义
|
||||
|
||||
================================================================================
|
||||
二十五、数组元素属性访问(重要)
|
||||
二十六、数组元素属性访问(重要)
|
||||
================================================================================
|
||||
|
||||
1. Array<any> 元素属性访问问题
|
||||
@@ -505,7 +549,7 @@
|
||||
- 解决:转换为 UTSJSONObject 或定义明确类型
|
||||
|
||||
================================================================================
|
||||
二十六、类型定义与可空类型(重要)
|
||||
二十七、类型定义与可空类型(重要)
|
||||
================================================================================
|
||||
|
||||
1. 类型定义中可空类型的处理
|
||||
@@ -543,7 +587,7 @@
|
||||
- 解决:修改类型定义为可空类型,或处理 null 情况
|
||||
|
||||
================================================================================
|
||||
二十七、模板中的可空类型处理(重要)
|
||||
二十八、模板中的可空类型处理(重要)
|
||||
================================================================================
|
||||
|
||||
1. 模板中可选链限制
|
||||
@@ -563,7 +607,7 @@
|
||||
- 解决:显式判断 null 后再访问属性
|
||||
|
||||
================================================================================
|
||||
二十八、解构赋值限制(重要)
|
||||
二十九、解构赋值限制(重要)
|
||||
================================================================================
|
||||
|
||||
1. UTS 中解构赋值可能有问题
|
||||
@@ -583,7 +627,7 @@
|
||||
- 避免使用解构赋值
|
||||
|
||||
================================================================================
|
||||
二十九、API 响应数据处理(重要)
|
||||
三十、API 响应数据处理(重要)
|
||||
================================================================================
|
||||
|
||||
1. response.data 返回 Any? 类型
|
||||
@@ -630,7 +674,7 @@
|
||||
- 解决:显式声明数组类型
|
||||
|
||||
================================================================================
|
||||
三十、ref 对象字面量类型(重要)
|
||||
三十一、ref 对象字面量类型(重要)
|
||||
================================================================================
|
||||
|
||||
1. ref 对象字面量必须定义类型
|
||||
@@ -665,7 +709,7 @@
|
||||
- 解决:定义 type 并在 ref 中指定泛型类型
|
||||
|
||||
================================================================================
|
||||
三十一、if 条件与可空类型(重要)
|
||||
三十二、if 条件与可空类型(重要)
|
||||
================================================================================
|
||||
|
||||
1. if 条件必须是 boolean 类型
|
||||
@@ -695,7 +739,7 @@
|
||||
- 解决:使用 != null 判断
|
||||
|
||||
================================================================================
|
||||
三十二、throw 语句限制(重要)
|
||||
三十三、throw 语句限制(重要)
|
||||
================================================================================
|
||||
|
||||
1. throw 语句不能抛出 Any 类型
|
||||
@@ -727,7 +771,7 @@
|
||||
- 解决:处理错误而非抛出,或创建 Error 对象
|
||||
|
||||
================================================================================
|
||||
三十三、模板中的可选链与属性访问(重要)
|
||||
三十四、模板中的可选链与属性访问(重要)
|
||||
================================================================================
|
||||
|
||||
1. 模板中可选链限制
|
||||
@@ -769,7 +813,7 @@
|
||||
- 解决:定义明确类型,使用三元表达式代替可选链
|
||||
|
||||
================================================================================
|
||||
三十四、数组操作限制(重要)
|
||||
三十五、数组操作限制(重要)
|
||||
================================================================================
|
||||
|
||||
1. 展开运算符 [...arr] 不支持
|
||||
|
||||
Reference in New Issue
Block a user