当前位置:网站首页>【报错】 “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
}
边栏推荐
- XML的解析
- Significance of acrel EMS integrated energy efficiency platform in campus construction
- It's too convenient. You can complete the code release and approval by nailing it!
- 取得PMP證書需要多長時間?
- Face recognition 5- insight face padding code practice notes
- If you open an account of Huatai Securities by stock speculation, is it safe to open an account online?
- He worked as a foreign lead and paid off all the housing loans in a year
- 图解网络:什么是网关负载均衡协议GLBP?
- Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
- 打新债开户注册安全吗?有没有风险的?靠谱吗?
猜你喜欢
Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC
ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
How to apply for PMP project management certification examination?
45 year old professor, she threw two super unicorns
Font design symbol combination multifunctional wechat applet source code
Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
Verilog tutorial (11) initial block in Verilog
Application of fire fighting system based on 3D GIS platform
微服务(Microservice)那点事儿
Etcd database source code analysis - brief process of processing entry records
随机推荐
Fast analysis -- easy to use intranet security software
MIT-6.824-lab4B-2022(万字思路讲解-代码构建)
Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
如何在外地外网电脑远程公司项目?
The pit of sizeof operator in C language
Summer challenge brings you to play harmoniyos multi terminal piano performance
Verilog tutorial (11) initial block in Verilog
圖解網絡:什麼是網關負載均衡協議GLBP?
Fast parsing intranet penetration helps enterprises quickly achieve collaborative office
打新债开户注册安全吗?有没有风险的?靠谱吗?
Design of emergency lighting evacuation indication system for urban rail transit station
Using the uniapp rich text editor
How to avoid arc generation—— Aafd fault arc detector solves the problem for you
图解网络:什么是网关负载均衡协议GLBP?
Introduction to ACM combination counting
人脸识别5- insight-face-paddle-代码实战笔记
如何报考PMP项目管理认证考试?
The input of uniapp is invalid except for numbers
Jar batch management gadget
模板的进阶