Answer the question
In order to leave comments, you need to log in
How to get the value of a VueJS variable?
JS
var socket = new WebSocket("ws://" + window.location.host + ":8081/")
new Vue({
delimiters: ['{>', '<}'],
el: '#patient_history',
data: {
department: ''
},
methods: {
getWebSocket: function () {
var self = this
socket.onopen = function () {
console.log("Соединение установлено.");
console.log(self.department)
socket.send(document.location)
};
socket.onclose = function (event) {
if (event.wasClean) {
alert('Соединение закрыто чисто');
} else {
alert('Обрыв соединения'); // например, "убит" процесс сервера
}
alert('Код: ' + event.code + ' причина: ' + event.reason);
};
socket.onmessage = function (event) {
console.log(event.data)
};
socket.onerror = function (error) {
alert("Ошибка " + error.message);
};
},
},
created: function () {
console.log(this.department)
this.getWebSocket()
}
})
<b>Отделение:</b> {{ current_history.department }} <span v-model="department">{{ current_history.department.id }}</span>
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