当前位置:网站首页>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文件删除掉
然后下载报错的依赖包
然后在启动项目即可!!!
边栏推荐
- Brief introduction to common sense of Zhongtai
- [shutter] shutter open source project reference
- MFC文件操作
- Many to one, one to many processing
- Mapper agent development
- AcWing_188. 武士风度的牛_bfs
- Xcode real machine debugging
- 1380. Lucky numbers in the matrix
- Explain in detail the process of realizing Chinese text classification by CNN
- 开发知识点
猜你喜欢
实用系列丨免费可商用视频素材库
Highly available cluster (HAC)
67 page overall planning and construction plan for a new smart city (download attached)
How to set automatic reply for mailbox and enterprise mailbox?
2022 latest and complete interview questions for software testing
Ideal car × Oceanbase: when the new forces of car building meet the new forces of database
JDBC Exercise case
35页危化品安全管理平台解决方案2022版
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
CADD course learning (4) -- obtaining proteins without crystal structure (Swiss model)
随机推荐
Master the development of facial expression recognition based on deep learning (based on paddlepaddle)
yolov5test. Py comment
Mapper agent development
Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
Speech recognition Series 1: speech recognition overview
Xcode real machine debugging
[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)
接口自动化覆盖率统计——Jacoco使用
MFC gets the current time
Interface switching based on pyqt5 toolbar button -1
返回二叉树两个节点间的最大距离
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
Interface switching based on pyqt5 toolbar button -2
Returns the maximum distance between two nodes of a binary tree
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
95页智慧教育解决方案2022
leetcode 650. 2 keys keyboard with only two keys (medium)
Installing redis under Linux
JDBC practice cases