欢迎入坑ArkUI-X项目,一套代码跨平台开发的梦乡。
//@ts-ignore
这不是一个普通注释,这是专门用来规避一些仅能在harmonyOS平台运行的代码。比如云数据库、AGC认证服务。
当你在构建中报错提示:can't support crossplatform application.
ERROR: ArkTS:ERROR File: xxxxxxxxxx
'lessThanOrEqualTo' can't support crossplatform application.
那么找到这一行代码
直接使用//@ts-ignore即可。
不行???
那你一定是在.ets文件里。
请把该代码剥离,放到.ts文件内。
// 查询当天的数据
//@ts-ignore
let condition = new cloudDatabase.DatabaseQuery(records_table);
//@ts-ignore
condition.equalTo('userId', uid)
只要报错的地方,都加上//@ts-ignore。
但是,要注意一些因为你写法习惯造成的困扰。比如说:
//@ts-ignore
condition.equalTo('userId', uid)
//@ts-ignore
.and()
//@ts-ignore
.greaterThanOrEqualTo('startDate'
这种链式代码,建议写成一行。
//@ts-ignore
condition.equalTo('userId', uid).and().greaterThanOrEqualTo('startD
或者,使用//@ts-nocheck禁用整个文件的类型检查。不过,你要小心整个文件没有类型检查,排查错误的坑会一个接一个。