Answer the question
In order to leave comments, you need to log in
How to connect Vue and application logic?
Greetings. There is a simple question, but it prevents you from moving forward in working on the application. I am doing a group chat with rooms on webrtc as part of the training.
The meaning is this. There are 2 variables in a vacuum.
// ид пользователя, просто string переменная
var userId = "";
// переменная для хранения списка комнат, к которым можно подключиться
var roomsList = [];
serverConnect({
serverUrl: "ws://127.0.0.1:0001",
success(plugin) {
plugin.connect({
success() {
userId = generateUserIdString();
plugin.send({"message": "getRoomsList"});
},
onmessage(msg) {
if(msg.type == "gotRoomsList") {
roomsList = msg.roomsList;
}
},
});
},
});
var app = Vue.createApp({
data() {
return {
userId: "",
roomsList: [],
};
},
}).mount("#app");
<div id="app">
<div>{{ userId }}</div>
<div>
<ul>
<li v-for="room in roomsList">{{ room.name }}</li>
</ul>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question