this.$message.success 输出undefined

问题代码:

//接收消息
messageArrived: function (res) {console.log("res:" + res);//正常输出console.log("typeof: " + typeof res); //输出objthis.$message.success(res);//输出undefinedthis.$notification.open({message: "消息通知:",description: res,}),//输出undefined
},

问题原因:

经 typeof res 查看 参数 res 类型为 obj 对象类型, this.$message.success 、 this.$notification.open 不能输出 obj ,如果参数类型是 obj 将输出为 undefined 。

解决办法:

显式转化成字符串类型

//接收消息
messageArrived: function (res) {console.log("res:" + res);//正常输出console.log("typeof: " + typeof res); //输出objthis.$message.success(res+"");//输出undefinedthis.$notification.open({message: "消息通知:",description: res+"",}),//输出undefined
},


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部