当前位置:网站首页>【报错】 “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
}
边栏推荐
- Five papers recommended for the new development of convolutional neural network in deep learning
- Acrel-EMS综合能效平台在校园建设的意义
- ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
- 公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!
- 微服务(Microservice)那点事儿
- Font design symbol combination multifunctional wechat applet source code
- 打新债开户注册安全吗?有没有风险的?靠谱吗?
- 人脸识别5- insight-face-paddle-代码实战笔记
- Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
- Combien de temps faut - il pour obtenir un certificat PMP?
猜你喜欢

如何避免电弧产生?—— AAFD故障电弧探测器为您解决

Verilog tutorial (11) initial block in Verilog

How to use fast parsing to make IOT cloud platform

Hash table, hash function, bloom filter, consistency hash

端口映射和端口转发区别是什么

Some basic functions of enterprise projects are developed, and important things are saved to online first a

如何报考PMP项目管理认证考试?

如何在外地外网电脑远程公司项目?

快解析——好用的内网安全软件

多回路仪表在基站“转改直”方面的应用
随机推荐
机器人强化学习——Learning Synergies between Pushing and Grasping with Self-supervised DRL (2018)
uniapp 除了数字,其他输入无效
Cross domain request
Solve the problem that the virtual machine cannot be remotely connected through SSH service
取得PMP证书需要多长时间?
Selected cutting-edge technical articles of Bi Ren Academy of science and technology
Meet ThreadPoolExecutor
Fast parsing intranet penetration helps enterprises quickly achieve collaborative office
Illustrated network: what is gateway load balancing protocol GLBP?
22-07-02周总结
Chinese verification of JS regular expressions (turn)
Best practice case of enterprise digital transformation: introduction and reference of cloud based digital platform system security measures
The pit of sizeof operator in C language
Hologres Query管理及超时处理
How to effectively monitor the DC column head cabinet
How to do the project of computer remote company in foreign Internet?
业务实现-日志写到同一个行数据里面
打新债开户注册安全吗?有没有风险的?靠谱吗?
用快解析内网穿透实现零成本自建网站
MIT-6.824-lab4B-2022(万字思路讲解-代码构建)