Answer the question
In order to leave comments, you need to log in
How to automatically send information when opening a page?
I have a page that has a form:
<form v-on:submit="send">
<div class="message" v-for="message in messages">
@{{ message }}
</div>
<input id="message"/>
<button>Отправить</button>
</form>
var socket = io('http://cniishub.ru:8080/');
new Vue({
el: '#app',
data: {
messages: [],
message: 'HW',
},
ready: function () {
socket.on('eventClient', function (data) {
this.messages.push(data);
}.bind(this));
},
methods: {
send: function (e) {
e.preventDefault();
socket.emit('eventServer', location.pathname);
this.message = null;
}
}
})
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