this.socket.emit('new-message', {
chat: {
name: this.$route.params.id
},
user: {
name: this.UserInfo.login
},
message: this.NewMessage,
});
socket.on('new-message', data => {
io.emit('update-chat', {
user: data.user.name,
message: data.message,
date: date,
});
});
io: {
// module options
sockets: [{
name: 'main',
url: process.env.NODE_ENV !== 'production'? 'http://localhost:8080' : 'http://194.194.194.194:8080',
default: true,
}]
}
<template>
...
<p class="lf-news-item__date">
<span> {{ item.date.split(' ')[0] }} </span>
</p>
...
</template>
Vue.use(window.vuelidate.default)
const { required, minLength, maxLength } = window.validators
new Vue({
el: "#app",
data: {
input: '',
info: 20
},
validations: {
input: {
required,
maxLength: maxLength(this.info.id || 20)
}
},
methods: {
getInfo: async function() {
let res = await fetch("https://jsonplaceholder.typicode.com/todos/20");
this.info = await res.json().id;
},
onSubmit() {
if (this.$v.$invalid) {
this.$v.$touch();
return;
}
}
},
async mounted() {
await this.getInfo();
}
})
const button = document.querySelectorAll('.button')
const item = document.querySelectorAll('.item')
function buttonClick() {
button.forEach((el, index) => {
el.addEventListener('click', () => {
button.forEach(elem => {
elem.classList.toggle('yellow');
elem.classList.toggle('red');
});
item.forEach((elem, id) => {
elem.style.display = index === id ? 'block' : 'none';
})
});
})
}
buttonClick();
получить данные из $store (vuex), поработать с ними,- getters
и в случае чего сохранить обратно во vuex.- mutations