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

然后下载报错的依赖包
然后在启动项目即可!!!
边栏推荐
- Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
- Practical series - free commercial video material library
- ArrayList分析2 :Itr、ListIterator以及SubList中的坑
- Agnosticism and practice makes perfect
- JS interviewer wants to know how much you understand call, apply, bind no regrets series
- cocospods 的使用
- 返回二叉树中最大的二叉搜索子树的大小
- Ideal car × Oceanbase: when the new forces of car building meet the new forces of database
- Fusion de la conversion et de la normalisation des lots
- 判断二叉树是否为满二叉树
猜你喜欢

RTP 接发ps流工具改进(二)

2022 latest and complete interview questions for software testing

Happy Lantern Festival, how many of these technical lantern riddles can you guess correctly?

QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
![[shutter] open the third-party shutter project](/img/1a/e35d0180612d7e79b55e7818193740.jpg)
[shutter] open the third-party shutter project

Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity

JDBC练习案例

The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north

35页危化品安全管理平台解决方案2022版

How to apply for company email when registering in company email format?
随机推荐
Agnosticism and practice makes perfect
[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)
[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
容器运行时分析
Top Devops tool chain inventory
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
Leetcode relaxation question - day of the week
Flexible combination of applications is a false proposition that has existed for 40 years
Detailed explanation of 'viewpager' in compose | developer said · dtalk
Mapper代理开发
JSON数据传递参数
Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
数据集-故障诊断:西储大学轴承的各项数据以及数据说明
How to apply for company email when registering in company email format?
开源了 | 文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开
yolov5train. py
附加:token;(没写完,别看…)
I've been interviewed. The starting salary is 16K
Returns the maximum distance between two nodes of a binary tree