const obj = arr.reduce((result, item) => {
const [key, value] = item.split('=');
if (!result[key]) {
result[key] = [];
}
result[key].push(value);
return result;
}, {})
{
utmTerm: ['java', 'javascript', 'swift'],
}
correct_date = `${hour}:${min}`;
// correct_date = `${hour}:${min}:${sec}`;
const getTimeString = () => {
const subbed = new Date();
const hour = subbed.getHours().toString().padStart(2, '0');
cosnt min = subbed.getMinutes().toString().padStart(2, '0');
const sec = subbed.getSeconds().toString().padStart(2, '0');
return `${hour}:${min}:${sec}`;
}
let clock = document.getElementById('clock')
setInterval(() => {
clock.innerHTML = getTimeString();
}, 1000);
export default {
data() {
return {
myVars: {
a: 1,
b: "some",
c: [1, 2, 3],
},
data: ['a', 'b', 'c'],
}
}
}
<div v-for="(elem, key) in data" :="key">{{ myVars[elem] }}</div>
export default {
data() {
return {
a: 1,
b: "some",
c: [1, 2, 3],
data: ['a', 'b', 'c'],
}
},
methods: {
getDataValue(param) {
return this[param] || null;
},
},
}
<div v-for="(elem, key) in data" :="key">{{ getDataValue(elem) }}</div>
if ($(this).find('input[name="DATA[NAME]"]').val().length < 2 ) {
return (alert("Введите имя"), !1)
} else if (0 == IsEmail(t)) {
return (alert("Введите корректный email"), !1)
} else {
return ($.ajax({...тут отправка формы})
}
<component-one v-on:click-some-button="hideBlockkInOtherComponent"></component-one>
<component-two ref="othercomponent"></component-two>
methods: {
hideBlockkInOtherComponent () {
this.$refs.othercomponent.hideBlock();
}
}
<div><button v-on:click="sendClickForParent">click</button></div>
methods: {
sendClickForParent () {
this.$emit('click-some-button');
}
}
<div>
<div v-if="showBlock">my block</div>
</div>
data () {
return {
showBlock: true,
};
},
methods: {
hideBlock () {
this.showBlock = false;
}
}
const array = ['я в Симбирск,', 'в трактире.', '...']
const order = [3, 7, 0, 8, 11, 5, 9, 6, 4, 1, 12, 2, 10]
const strings = order.reduce((strings, number) => [...strings, array[number]], [])
const result = strings.join(' ')