请求后台数据时数据拿到了,赋值时控制台报错

控制台报错后台响应页面赋值失败,因为那个报错请教各位大佬,在使用axios请求后端数据的时候数据拿到了,在进行赋值的时候控制台报错Uncaught (in promise) TypeError: Cannot set property 'type' of undefined,我的代码如下:

getList(){  
    getBanner({  
        pageNumber:this.formInline.currentPage,  
        pageSize:this.formInline.pageSize  
    }).then(res=>{  
        this.tableData=res.data;  
        this.total=res.totalNumber  
    })  
},

请问这是怎么回事啊?

阅读 2.2k
2 个回答

你这是element-ui报的错
源码我看是message相关的

['success', 'warning', 'info', 'error'].forEach(function (type) {
    main_Message[type] = function (options) {
        if (typeof options === 'string') {
            options = {
                message: options
            };
        }
        options.type = type;  // 这行报的错
        return main_Message(options);
    };
});

你找找你哪里调用了这个消息提示,应该是出现了这样的情况

this.$message.success(undefined) // 或者是warning等其他的方法

图片.png
element-ui报的,你不是传给elemet的组件的prop传了个undeifined进去

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题