【vue】前端报错:Cannot read properties of undefined (reading ‘split‘)

【vue】前端报错:Cannot read properties of undefined (reading ‘split‘),第1张

问题的出现:

由于在做项目的时候,想实现数字转成汉字:

但是在控制台会报一个Cannot read properties of undefined (reading ‘split‘)
在调试的时候回发现数据会慢一步出现

问题出现的原因:

由于是发请求得到这个studentinfo这个数据,因此在没得到数据之前,它是会为undefined,这个时候是没有方法使用的。
简单来说就是数据异步的问题了。

解决的方法:

当数据为undefined的时候,将这个剔除,就是当它不为undefined的时候来执行,因此添加一个if语句来判断就行

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1323265.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-12
下一篇 2022-06-12

发表评论

登录后才能评论

评论列表(0条)

保存