当前位置:网站首页>[error reporting] "typeerror: cannot read properties of undefined (reading 'split')“
[error reporting] "typeerror: cannot read properties of undefined (reading 'split')“
2022-07-05 00:09:00 【Blog Zhu hukang】
Report the wrong question
In the use of split() Method is divided into strings , The red information is as follows :Cannot read properties of undefined (reading ‘split‘)
Error reporting analysis
Before dividing the data , First judge whether the current data is empty ; If you don't judge the data , Can cause an exception . So in calling splid() Function before , You need to make a non empty judgment on the data that currently needs to be segmented ( Or call when the data is not empty ).
Error reporting solution
Before dividing the data , First judge whether the current data is empty ; If you don't judge the data , Can cause an exception . So in calling splid() Function before , You need to make a non empty judgment on the data that currently needs to be segmented ( Or call when the data is not empty ).
const imgUrl = "https://tu.cloud.cn/flower/flower-size.jpg?size=1800";
// When the data is not empty
if(imgUrl) {
// Intercept Then splice the new string
const newImgUrl = imgUrl.split('?')[0] + "?size=600";
console.log(newImgUrl); //https://tu.cloud.cn/flower/flower-size.jpg?size=600
}
边栏推荐
- [JS] - [dynamic planning] - Notes
- 【报错】 “TypeError: Cannot read properties of undefined (reading ‘split‘)“
- If you open an account of Huatai Securities by stock speculation, is it safe to open an account online?
- abc 258 G - Triangle(bitset)
- 海思3559万能平台搭建:YUV422的踩坑记录
- P4281 [AHOI2008]紧急集合 / 聚会(LCA)
- [IELTS reading] Wang Xiwei reading P4 (matching1)
- Go pit - no required module provides Package: go. Mod file not found in current directory or any parent
- 巩固表达式C# 案例简单变量运算
- Acwing164. Accessibility Statistics (topological sorting +bitset)
猜你喜欢
[JS] - [sort related] - Notes
Application of fire fighting system based on 3D GIS platform
Netcore3.1 JSON web token Middleware
Fast analysis -- easy to use intranet security software
Acrel-EMS综合能效平台在校园建设的意义
城市轨道交通站应急照明疏散指示系统设计
【雅思阅读】王希伟阅读P4(matching1)
uniapp微信小程序拿来即用的瀑布流布局demo2(方法二)(复制粘贴即可使用,无需做其他处理)
[IELTS reading] Wang Xiwei reading P4 (matching1)
Parsing of XML
随机推荐
Meet ThreadPoolExecutor
积分商城游戏设置的基本要点
Fast parsing intranet penetration helps enterprises quickly achieve collaborative office
【雅思阅读】王希伟阅读P3(Heading)
同事的接口文档我每次看着就头大,毛病多多。。。
How to apply for PMP project management certification examination?
JS 将伪数组转换成数组
【路径规划】RRT增加动力模型进行轨迹规划
How long does it take to obtain a PMP certificate?
电力运维云平台:开启电力系统“无人值班、少人值守”新模式
Hologres Query管理及超时处理
Combien de temps faut - il pour obtenir un certificat PMP?
IELTS examination process, what to pay attention to and how to review?
C语言中sizeof操作符的坑
"Xiaodeng" domain password policy enhancer in operation and maintenance
[Peking University] tensorflow2.0-1-opening
快解析内网穿透帮助企业快速实现协同办公
Hong Kong Jewelry tycoon, 2.2 billion "bargain hunting" Giordano
挖财学院开户安全的吗?开户怎么开?
如何在外地外网电脑远程公司项目?