问题代码:
//接收消息
messageArrived: function (res) {
console.log("res:" + res);//正常输出
console.log("typeof: " + typeof res); //输出obj
this.$message.success(res);//输出undefined
this.$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); //输出obj
this.$message.success(res+"");//输出undefined
this.$notification.open({
message: "消息通知:",
description: res+"",
}),//输出undefined
},