当前位置:网站首页>TypeError: Cannot read properties of undefined (reading ***)
TypeError: Cannot read properties of undefined (reading ***)
2022-07-02 22:54:00 【Z_Xshan】
在别的地方看了好几个版本
版本一
1.检查你的data定义的属性是不是没有你用到的这个属性,没有的话就定义一个,如下:
#template
<div class="he-info__item">
<span class="he-label">收货人姓名:</span>
<span class="he-value">{
{ detail.buyer.name }}</span>
</div>
<div class="he-info__item">
<span class="he-label">联系方式:</span>
<span class="he-value">{
{ detail.buyer.mobile }}</span>
</div>
#js
export default {
data () {
detail: {
buyer: {
name: "",
mobile: "",
},
user: {
nickname: "",
},
},
}
}
版本二
//2.也可能是后端返回给你的数据没有这个属性 或者 返回的有的有数据 有的是 null ,
// 这时候就不能写 {
{ item.xxx || “” }} 不然会报错 Cannot read properties of undefined (reading ‘xxx‘)“ 可以这么解决 如下:
#template
<div v-if="!!item.invite">{
{ item.invite.nickname }}</div> //有这个属性才显示
//或者这样也行
<div v-if="item?.invite">{
{ item.invite.nickname }}</div> //有这个属性才显示
<div v-else>{
{ "" }}</div> //没有返回 或者 null 直接填 “”版本三
//3.网上还有一种就是 视图未更新 数据还没返回 你就开始使用这个属性 可以加个
this.$nectTick (()=>{//获取数据}) 包裹一下我的解决方法如果没有代码错误的话可以重新下载依赖试一试
把node_modules删掉然后
npm i
或
cnpm i如果是下载包在启动项目时报错 那这个方法就有点搂了
我们可以试试把src下.umi文件删除掉

然后下载报错的依赖包
然后在启动项目即可!!!
边栏推荐
- MATLAB signal processing [Q & a notes-1]
- What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
- MFC文件操作
- I've been interviewed. The starting salary is 16K
- 秒杀系统设计
- 程序分析与优化 - 9 附录 XLA的缓冲区指派
- Matlab 信号处理【问答笔记-1】
- Program analysis and Optimization - 9 appendix XLA buffer assignment
- 洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
- 开发知识点
猜你喜欢

Talk with the interviewer about the pit of MySQL sorting (including: duplicate data problem in order by limit page)

MySQL基础

带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)

How QT exports data to PDF files (qpdfwriter User Guide)

How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base

Interpretation of new plug-ins | how to enhance authentication capability with forward auth
![洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表](/img/4a/ab732c41ea8a939fa0983fec475622.png)
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表

JDBC练习案例

Mapper代理开发

实用系列丨免费可商用视频素材库
随机推荐
接口自动化覆盖率统计——Jacoco使用
Brief introduction to common sense of Zhongtai
Interface switching based on pyqt5 toolbar button -2
How to maintain the brand influence of clothing enterprises
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
Leetcode relaxation question - day of the week
Digital twin smart factory develops digital twin factory solutions
Missing number
Improvement of RTP receiving and sending PS stream tool (II)
JSON data transfer parameters
Custom throttling function six steps to deal with complex requirements
leetcode 650. 2 keys keyboard with only two keys (medium)
[array] binary search
Happy Lantern Festival, how many of these technical lantern riddles can you guess correctly?
leetcode 650. 2 keys keyboard with only two keys (medium)
Wechat applet basic learning (wxss)
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
教育学大佬是怎么找外文参考文献的?
Linux 下安装 redis