当前位置: 首页 > article >正文

uniapp-x js 限制

1.String(str) 不允许,android模拟室报错,找不到String

2.JSON.parse不接受泛类型

export const genData = function<T> (initData:T) : T {
	return JSON.parse<T>(JSON.stringify(initData))!;//不可以,必须明确类型
}

error: Cannot use 'T' as reified type parameter. Use a class instead.‌

但是却可以这样写

export function UtilUpdateState<T>(options:UpdateStateArgs):T{
	const {key,value,state,localKey,setCache}=options;
	state[key]=value;
	if(setCache==true){
		setLocalStore(state,localKey)
	}
	//为啥这里可以as
	return state as T;
}

却不可以这样写

//初始化数据,生成数据,不允许这样写
export  function genData<T> (initData:UTSJSONObject) : T {
	const obj= JSON.parse<UTSJSONObject>(JSON.stringify(initData))!;
	return obj as T;
}

神奇吧~~~~

版本hbuilderx:4.56

3.数字类型不能和字符串对比,例如

1=="1" ‌
error: Operator '==' cannot be applied to 'Number' and 'String'‌


http://www.kler.cn/a/587728.html

相关文章:

  • AUTOSAR 网络安全 架构
  • Spring Boot + InfluxDB 批量写入(同步、异步、重试机制)
  • AI自动文献综述——python先把知网的文献转excel
  • EB-Cable许可管理中的数据安全与隐私保护
  • UE材质RadialGradientExponential
  • WebSocket 使用教程
  • 前端无限滚动内容自动回收技术详解:原理、实现与优化
  • 在 VMware 中安装 Ubuntu 的超详细实战分享
  • Postman用JSON格式数据发送POST请求及注意事项
  • LeetCode 2226. Maximum Candies Allocated to K Children(2025/3/14 每日一题)
  • 【MySQL】数据库简要介绍和简单应用
  • 分享一个sql统计的客户需求
  • Vue2+Vant2 项目初学
  • 故障诊断——neo4j入门
  • centos7通过yum安装redis
  • golang算法回溯
  • spring boot 发送邮件验证码
  • 解锁健康密码:拥抱养生,重塑生活
  • python笔记2
  • Ubuntu 18,04 LTS 通过APT安装mips64el的交叉编译器。