当前位置:网站首页>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文件删除掉

然后下载报错的依赖包
然后在启动项目即可!!!
边栏推荐
- Missing number
- Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
- leetcode 650. 2 keys keyboard with only two keys (medium)
- MATLAB signal processing [Q & a notes-1]
- collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
- What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
- Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
- JDBC練習案例
- Intranet penetration | teach you how to conduct intranet penetration hand in hand
- The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
猜你喜欢

实用系列丨免费可商用视频素材库

容器运行时分析

Master the development of facial expression recognition based on deep learning (based on paddlepaddle)

JDBC練習案例

35 pages dangerous chemicals safety management platform solution 2022 Edition

Digital twin visualization solution digital twin visualization 3D platform

List of major chip Enterprises

Data set - fault diagnosis: various data and data description of bearings of Western Reserve University

Interface difference test - diffy tool

How to apply for company email when registering in company email format?
随机推荐
What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
JDBC tutorial
基于OpenCV实现口罩识别
How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
附加:token;(没写完,别看…)
Fusion de la conversion et de la normalisation des lots
请求与响应
Leetcode relaxation question - day of the week
JSON数据传递参数
Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
Judge whether the binary tree is full binary tree
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
I've been interviewed. The starting salary is 16K
How much do you know about synchronized?
1380. Lucky numbers in the matrix
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
Returns the size of the largest binary search subtree in a binary tree
MATLAB signal processing [Q & a notes-1]
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举