blur
, а не focus
toUpperCase
не у строки, а у массива - забыто [0]
input.addEventListener('blur', function() {
const value = this.value.trim();
if (value) {
this.value = value
.split(/\s+/)
.map(n => n[0].toUpperCase() + n.slice(1))
.join(' ');
}
});
// или
input.addEventListener('blur', ({ target: t }) => {
t.value = t.value
.trim()
.replace(/\s+/g, ' ')
.replace(/(^|\s)\S/g, m => m.toUpperCase());
});
created() {
accessAPI().then(result => this.api = result);
},
<imgMap :api="api"></imgMap>
<imgMap v-if="api" :api="api"></imgMap>
не могу напрямую вызывать асинхронные методы из обьекта они недоступны. Сейчас я решил проблему так:
props: { api : Object }, data() { return { apiLocal : null } } async mounted() { this.apiLocal = await this. api; await this.apiLocal.methods1(); }
const getPrimitiveProps = (obj) =>
Object.entries(obj).reduce((acc, [ k, v ]) => ({
...acc,
...(v instanceof Object ? getPrimitiveProps(v) : { [k]: v }),
}), {});
const getPrimitiveProps = (obj) =>
Object.assign({}, ...Object.entries(obj).map(([ k, v ]) =>
v instanceof Object ? getPrimitiveProps(v) : { [k]: v }
));
document.addEventListener('keydown', e => {
if (e.key === 'Backspace' && e.target !== display) {
display.value = display.value.slice(0, -1);
// или
display.value = display.value.substring(0, display.value.length - 1);
// или
display.value = display.value.replace(/.$/, '');
// или
display.value = display.value.match(/.*(?=.$)/);
// или
display.value = [...display.value].filter((n, i, a) => -~i < a.length).join('');
}
});
$repeated = false;
for ($i = 1; $i < count($arr) && !$repeated; $i++) {
$repeated = $arr[$i] === $arr[$i - 1];
}
printf('повторения %s', $repeated ? 'есть' : 'отсутствуют');
foreach ($arr as $i => $n) {
if ($i && $n === $arr[~-$i]) {
echo "по индексу $i повторяется значение $n\n";
}
}
есть модальное окно-увеличение картинки, нажимая на него, маршрут сбивается
<a :id="item.id" v-b-modal="'img-'+item.id" href="#" >
@click.prevent
. $(document).click(function(e) {
if (!$panel.has(e.target).length && $panel.hasClass('visible')) {
hidePanel();
}
});
const ip = str.split(':', 1)[0];
const ip = str.slice(0, str.indexOf(':'));
const ip = str.match(/[\d.]+/).pop();
const ip = str.replace(/:.+$/, '');
const [ ip ] = /.+(?=:)/.exec(str);
animation-delay
, а для "задержки" указываете в keyframes
промежуток без изменения значения:<div class="wrapper">
<div class="block">hello, world!!</div>
<div class="block">fuck the world</div>
<div class="block">fuck everything</div>
</div>
.wrapper {
width: 150px;
height: 20px;
font-size: 16px;
border: 1px solid #000;
overflow: hidden;
position: relative;
}
@keyframes movingTopToBottom {
0% {
top: 55px;
}
40%, 60% {
top: 0px;
}
100% {
top: -55px;
}
}
.block {
animation: movingTopToBottom 6s linear infinite;
position: absolute;
}
.block:nth-child(1) { animation-delay: 0s; }
.block:nth-child(2) { animation-delay: -4s; }
.block:nth-child(3) { animation-delay: -2s; }
@focus="disabled = true"
@blur="disabled = false"
@mousedown="disabled = !disabled"
formMeta: [
{ type: '...', props: { ... } },
{ type: '...', props: { ... } },
....
],
<div v-for="{ type, props } in formMeta" class="form-item">
<component :is="type" v-bind="props"></component>
</div>
fieldset > .ui-checkboxradio-label {
width: 100%;
box-sizing: border-box;
text-align: left;
}
const plainToNested = (source, target = {}) =>
Object.entries(source).reduce((acc, [ path, val ]) => {
const keys = path.split('.');
const key = keys.pop();
keys.reduce((p, c) => p[c] = p[c] || {}, acc)[key] = val;
return acc;
}, target);