17:14:49.826 [plugin:uni:app-uts] 编译失败
17:14:49.826 error: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
17:14:49.826 public val Char.code: Int defined in kotlin
17:14:49.826 at pages/love/daily-earning/index.uvue:546:29
17:14:49.826 544| const res = await queryAlmanac(dateStr)
17:14:49.826 545| console.log('queryAlmanac res:', res)
17:14:49.826 546| if (res != null && res.code === 200) {
17:14:49.826 | ^
17:14:49.826 547| console.log('黄历数据:', res.data)
17:14:49.826 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:14:49.826 error: Unresolved reference: data
17:14:49.827 at pages/love/daily-earning/index.uvue:547:33
17:14:49.827 545| console.log('queryAlmanac res:', res)
17:14:49.827 546| if (res != null && res.code === 200) {
17:14:49.827 547| console.log('黄历数据:', res.data)
17:14:49.827 | ^
17:14:49.827 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:14:49.827 549| const yi = almanacData != null && typeof almanacData.yi === 'string' ? almanacData.yi : ''
17:14:49.827 error: Unresolved reference: data
17:14:49.827 at pages/love/daily-earning/index.uvue:548:32
17:14:49.827 546| if (res != null && res.code === 200) {
17:14:49.827 547| console.log('黄历数据:', res.data)
17:14:49.827 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:14:49.827 | ^
17:14:49.827 549| const yi = almanacData != null && typeof almanacData.yi === 'string' ? almanacData.yi : ''
17:14:49.827 550| const ji = almanacData != null && typeof almanacData.ji === 'string' ? almanacData.ji : ''
17:14:49.827 error: Unresolved reference: data
17:14:49.827 at pages/love/daily-earning/index.uvue:548:52
17:14:49.827 546| if (res != null && res.code === 200) {
17:14:49.827 547| console.log('黄历数据:', res.data)
17:14:49.827 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:14:49.828 | ^
17:14:49.828 549| const yi = almanacData != null && typeof almanacData.yi === 'string' ? almanacData.yi : ''
17:14:49.828 550| const ji = almanacData != null && typeof almanacData.ji === 'string' ? almanacData.ji : ''
17:14:49.828 开始差量编译...
17:14:50.119 代码编译报错?点击这里,AI智能诊断并修复!
17:14:52.284 error: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
17:15:20.573 public val Char.code: Int defined in kotlin
17:15:20.573 at pages/love/daily-earning/index.uvue:546:29
17:15:20.573 544| const res = await queryAlmanac(dateStr)
17:15:20.573 545| console.log('queryAlmanac res:', res)
17:15:20.573 546| if (res != null && res.code === 200) {
17:15:20.573 | ^
17:15:20.573 547| console.log('黄历数据:', res.data)
17:15:20.573 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:15:20.573 error: Unresolved reference: data
17:15:20.573 at pages/love/daily-earning/index.uvue:547:33
17:15:20.573 545| console.log('queryAlmanac res:', res)
17:15:20.573 546| if (res != null && res.code === 200) {
17:15:20.573 547| console.log('黄历数据:', res.data)
17:15:20.573 | ^
17:15:20.573 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:15:20.573 549| const yi = almanacData != null && typeof almanacData.yi === 'string' ? almanacData.yi : ''
17:15:20.573 error: Unresolved reference: data
17:15:20.573 at pages/love/daily-earning/index.uvue:548:32
17:15:20.573 546| if (res != null && res.code === 200) {
17:15:20.573 547| console.log('黄历数据:', res.data)
17:15:20.573 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:15:20.573 | ^
17:15:20.573 549| const yi = almanacData != null && typeof almanacData.yi === 'string' ? almanacData.yi : ''
17:15:20.573 550| const ji = almanacData != null && typeof almanacData.ji === 'string' ? almanacData.ji : ''
17:15:20.573 error: Unresolved reference: data
17:15:20.573 at pages/love/daily-earning/index.uvue:548:52
17:15:20.573 546| if (res != null && res.code === 200) {
17:15:20.573 547| console.log('黄历数据:', res.data)
17:15:20.573 548| const almanacData = res.data != null && res.data.almanacData != null ? res.data.almanacData : null
17:15:20.573 | ^
17:15:20.573 549| const yi = almanacData != null && typeof almanacData.yi === 'string' ? almanacData.yi : ''
17:15:20.573 550| const ji = almanacData != null && typeof almanacData.ji === 'string' ? almanacData.ji : ''
17:15:20.580 当前工程22个页面,正在编译为android class,此过程耗时较长...
17:15:20.593 [plugin:uni:app-uts] 编译失败
Qkings
- 发布:2026-03-04 17:33
- 更新:2026-03-04 17:33
- 阅读:14
hbuidex 打包安卓的时候一直提示各种数据格式问题,打包ios就没问题,是哪里配置不对吗
分类:uni-app x
1 个回复
Ask小助手 - Ask社区AI助手
报错信息集中在
pages/love/daily-earning/index.uvue第 546-548 行,提示:Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public val Char.code: Int defined in kotlinUnresolved reference: data说明在 uni-app x(uts) 编译为 Android 时,编译器把
res.code识别成了 Kotlin 的 Char.code 扩展属性,而不是你期望的 网络返回对象里的 code 字段。这通常是因为 类型推断失败,res被推断成了Char?或其他类型,而不是你预期的对象类型。✅ 解决方案(基于知识库)
根据 对话知识库中官方回复 和 优先知识库中类型推断失败的处理方式,你需要:
✅ 1. 显式声明
res的类型将
res显式声明为UTSJSONObject或其他你定义的类型,避免类型推断失败:或者如果你使用的是自定义类型:
✅ 2. 检查
queryAlmanac的返回类型定义确保
queryAlmanac的返回类型不是any?或Char?,而是明确的对象类型。例如:✅ 3. 避免使用
res != null && res.code === 200在 uts 中,建议使用可选链和空值合并:
✅ 总结
你遇到的问题是因为 uts 编译器在 Android 平台上对类型推断更严格,而 iOS 上可能容错性更高。解决方法是:
as或接口定义返回类型如需进一步参考,请查看官方文档:uni-app x 类型系统说明
要回复问题请先登录或注册
公告
更多>相关问题