当前位置:网站首页>【报错】 “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
}
边栏推荐
- Expand your kubecl function
- French scholars: the explicability of counter attack under optimal transmission theory
- S32 design studio for arm 2.2 quick start
- Skills in analyzing the trend chart of London Silver
- Introduction to ACM combination counting
- [IELTS reading] Wang Xiwei reads P4 (matching2 paragraph information matching question [difficult])
- Meet ThreadPoolExecutor
- PaddleOCR教程
- 微服务(Microservice)那点事儿
- PermissionError: [Errno 13] Permission denied: ‘data. csv‘
猜你喜欢
青海省国家湿地公园功能区划数数据、全国湿地沼泽分布数据、全国省市县自然保护区
OpenHarmony资源管理详解
How to apply for PMP project management certification examination?
同事的接口文档我每次看着就头大,毛病多多。。。
取得PMP证书需要多长时间?
Font design symbol combination multifunctional wechat applet source code
PMP certificate renewal process
How many triangles are there in the golden K-line diagram?
端口映射和端口转发区别是什么
[kotlin] the third day
随机推荐
French scholars: the explicability of counter attack under optimal transmission theory
[论文阅读] CarveMix: A Simple Data Augmentation Method for Brain Lesion Segmentation
Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC
快解析内网穿透帮助企业快速实现协同办公
雅思考试流程、需要具体注意些什么、怎么复习?
公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!
Introduction to ACM combination counting
股票账户佣金怎么调低,炒股佣金怎么调低网上开户安全吗
实战模拟│JWT 登录认证
Date time type and format in MySQL
机器人强化学习——Learning Synergies between Pushing and Grasping with Self-supervised DRL (2018)
Fast analysis -- easy to use intranet security software
Illustrated network: what is gateway load balancing protocol 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
用快解析内网穿透实现零成本自建网站
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection
Tester's algorithm interview question - find mode
abc 258 G - Triangle(bitset)
Intelligence test to see idioms guess ancient poems wechat applet source code
使用快解析搭建自己的minecraft服务器