当前位置:网站首页>【报错】 “TypeError: Cannot read properties of undefined (reading ‘split‘)“
【报错】 “TypeError: Cannot read properties of undefined (reading ‘split‘)“
2022-07-05 00:05:00 【博客zhu虎康】
报错问题
在使用 split()方法分割成字符串时,报红信息如下:Cannot read properties of undefined (reading ‘split‘)
报错分析
在对数据进行分割以前,要先判断当前数据是否存在为空的情况;如果不对数据进行判断,可能会导致异常。所以在调用 splid() 函数前,需要对当前需要进行分割的数据进行非空的判断(或者是当数据不为空的情况下调用)。
报错解决
在对数据进行分割以前,要先判断当前数据是否存在为空的情况;如果不对数据进行判断,可能会导致异常。所以在调用 splid() 函数前,需要对当前需要进行分割的数据进行非空的判断(或者是当数据不为空的情况下调用)。
const imgUrl = "https://tu.cloud.cn/flower/flower-size.jpg?size=1800";
// 当数据不为空的情况下
if(imgUrl) {
// 截取 再拼接新的字符串
const newImgUrl = imgUrl.split('?')[0] + "?size=600";
console.log(newImgUrl); //https://tu.cloud.cn/flower/flower-size.jpg?size=600
}
边栏推荐
- 快解析内网穿透帮助企业快速实现协同办公
- 人脸识别5- insight-face-paddle-代码实战笔记
- Pytoch --- use pytoch to realize linknet for semantic segmentation
- Font design symbol combination multifunctional wechat applet source code
- Hong Kong Jewelry tycoon, 2.2 billion "bargain hunting" Giordano
- ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
- 业务场景功能的继续修改
- S32 design studio for arm 2.2 quick start
- It's too convenient. You can complete the code release and approval by nailing it!
- Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
猜你喜欢

He worked as a foreign lead and paid off all the housing loans in a year

海思3559万能平台搭建:YUV422的踩坑记录

ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
![P3304 [SDOI2013]直径(树的直径)](/img/5c/984675bf4517481f80f54657c6c7ad.png)
P3304 [SDOI2013]直径(树的直径)

45岁教授,她投出2个超级独角兽

Microservice

【雅思阅读】王希伟阅读P3(Heading)

Solution record of jamming when using CAD to move bricks in high configuration notebook

城市轨道交通站应急照明疏散指示系统设计

Combien de temps faut - il pour obtenir un certificat PMP?
随机推荐
Is the account opening link of Huatai Securities with low commission safe?
Significance of acrel EMS integrated energy efficiency platform in campus construction
Etcd database source code analysis - brief process of processing entry records
Instructions for go defer
多回路仪表在基站“转改直”方面的应用
业务实现-日志写到同一个行数据里面
快解析内网穿透帮助企业快速实现协同办公
js正则表达式之中文验证(转)
机器人强化学习——Learning Synergies between Pushing and Grasping with Self-supervised DRL (2018)
如何报考PMP项目管理认证考试?
JS 将伪数组转换成数组
The input of uniapp is invalid except for numbers
Application of fire fighting system based on 3D GIS platform
如何将自己的代码作品快速存证,已更好的保护自己劳动成果
Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
[kotlin] the third day
Combien de temps faut - il pour obtenir un certificat PMP?
How to do the project of computer remote company in foreign Internet?
Best practice case of enterprise digital transformation: introduction and reference of cloud based digital platform system security measures
[monitoring] ZABBIX