报错TypeError: Cannot set property ‘type‘ of undefined
TypeError: Cannot set property ‘type’ of undefined报错问题
<script>
export default {data () {return {query: '',// 表格数据// username: "admin"// email: "adsfad@qq.com"// mobile: "12345678"// create_time: 1486720211// mg_state: true// id: 500// role_name: "主管"userlist: [],total: -1,pagenum: 1,pagesize: 2}},created () {this.getList()},methods: {async getList () {// query查询参数可以为空// pagenum当前页码不能为空// pagesize每页显示条数不能为空// 需要授权的 API ,必须在请求头中使用 Authorization 字段提供 token 令牌const AUTH_TOKEN = localStorage.getItem('token')this.$http.defaults.headers.common['Authorization'] = AUTH_TOKENconst res = await this.$http.get(`users?query=${this.query}&pagenum=${this.pagenum}&pagesize=${this.pagesize}`)console.log(res)const {data: {status,msg},data: {users,total}} = res.dataif (status === 200) {// 给表格数据赋值this.userlist = users// 给total赋值this.total = total// 提示this.$message.success(msg)} else {this.$message.warning(msg)}}}
}
</script>
错误原因:
const {data: {status,msg},data: {users,total}} = res.data
仔细看代码,发现const里面有两个对象,两个都是data,而后台返回的数据应该是一个data和一个meta。
这里也告诉小伙伴们,敲代码的时候一定要细心
报错TypeError: Cannot set property ‘type‘ of undefined相关推荐
- VUE中axios 报错 TypeError: Cannot set property ‘type‘ of undefined,
报错: 导致axios里then的方法不执行 问题: 后台数据没有传到前端导致传的是一片空 不是null也不是 undefined 是没有东西 导致resp响应为空在底层会报错 以上在catch里做逻 ...
- JS报错:Cannot read property 'type' of undefined
在做图片上传功能的时候,遇到了JS无法识别图片type的问题,在使用过程中是没有问题的,但是不知道为什么浏览器的Console报这个错误: Uncaught TypeError: Cannot rea ...
- VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法...
data里面做了定义 在方法里面进行赋值 用 this.info = repos.data 数据可以请求到,但是会报错 TypeError: Cannot set property 'listgrou ...
- Vue页面加载使用二级属性的时候报错TypeError: Cannot read property ‘name‘ of undefined“
<template v-if="tableData != undefined"><div><h3 style="padding:0px;te ...
- 微信小程序报错TypeError: Cannot read property ‘0‘ of undefined
开发小程序时在注册一个vant组件后使用时,报了一个错: TypeError: Cannot read property '0' of undefined 反复检查代码没有发现问题,而且之前使用其他组 ...
- Vue项目 报错TypeError [ERR INVALID ARG TYPE]: The “path“ argument must be of type string
# Vue项目 报错TypeError [ERR INVALID ARG TYPE]: The "path" argument must be of type string 卡了半 ...
- vue ui创建项目报错:Cannot read property ‘indexOf‘ of undefined解决方法
报错: Cannot read property 'indexOf' of undefined 报错翻译:无法读取未定义的属性"indexOf" 报错原因分析: vue/cli 的 ...
- 小程序报错 TypeError: Cannot read property getPreloadAdUnitIds ?
小程序打包报这个错 TypeError: Cannot read property 'getPreloadAdUnitIds' 按下图修改 基础库 就好了 关注 伴少年 更新各种小知识 蟹蟹
- laydate报Uncaught TypeError: Cannot read property 'appendChild' of undefined
laydate Uncaught TypeError: Cannot read property 'appendChild' of undefined 我遇到这个错误之后是从两个方向解决的问题 出现了 ...
最新文章
- JavaScript prototype
- html中label的寬度無法修改,如何设置HTML span、label 的宽度
- 变量是否在数组内c语言,函数内创建的数组在调用后,是否就不存在
- 阿里巴巴分布式事务利器Seata环境准备
- windows清理剪切板
- 计算神经生物学 计算机转生物,计算神经生物学的应用有哪些?
- 不同机器,打印速度相差巨大
- PMP笔记-项目管理过程中的审计类型
- linux中的sg工具,sg3_utils工具windows系统下的使用
- 华为云服务器查看备份文件,云服务器备份文件
- 12.14黄金白银欧美盘走势分析及期货原油操作建议
- 利用Javascript制作宾果(BINGO)游戏
- html qq消息弹窗提醒,能不能让QQ消息不再讨厌 QQ HD mini消息弹窗提醒的优化方案...
- 海康威视视频ocx控件开发总结
- python接入支付宝接口
- 泛微校招群面经历(一日游?)
- (1)有一函数: 当x<1时,y=x 当1<=x<10时,y=2x-1 当x>=10时,y=3x-11 编写程序输入x,输出y的值
- Linux定时清除缓存脚本与清除命令
- Mac下的终端(Terminal)简介
- MS Office Excel 2007/2003 资料下载汇总
热门文章
- 安全通过广州火车站攻略
- zzulioj:指针结构体 题解
- libvlc使用遇到的错误解决
- Numpy ravel和flatten区别
- python 打包 太大 精简_pyinstaller打包结果瘦身
- 在vue中使用百度地图API:区域显示3D棱柱、地点标注、信息提示
- 老年人计算机培训信息,铁四社区开展老年人计算机培训班
- a推b等价于非a或b_AB水固化注浆液配方,注浆液配方,水固化配方,灌浆堵漏防水配方【北京专业防水吧】...
- lua/require函数
- 2016年中国500强利润率最高的公司,中国500强最赚钱的40家公司,ROE最高的公司...