以下是代码:
const signalR = require("@microsoft/signalr");
export default {
name: "mainFrame",
data(){
return{
connection: "",
user: "",
message: "",
msgList: []
}
},
methods:{
init() {
this.connection = new signalR.HubConnectionBuilder()
.withUrl("http://111.111.1.111:11111/zxc", {})
.configureLogging(signalR.LogLevel.Error)
.build();
this.connection.on("ReceiveMessage", data => {
this.msgList.push(data);
});
this.connection.start();
},
},
created(){
this.init()
}