mixin list(...items)
ul.breadcrumbs
each item in items
li.breadcrumbs__item
a(href=item)= item
+list('https://www.google.ru/', 'https://toster.ru', 'https://toster.ru/q/590329')
mixin list(...items)
ul.breadcrumbs
each item in items
li.breadcrumbs__item
a(href='https://toster.ru/q/' + item)= item
+list(590329, 588072, 584712)
mixin list(...items)
ul.breadcrumbs
each item in items
li.breadcrumbs__item
a(href=item.link)= item.text
+list({ link: 'https://www.google.ru/', text: 'google' }, { link: 'https://toster.ru', text: 'toster' }, { link: 'https://toster.ru/q/590329', text: 'ваш вопрос' })
Как привязать обработку событию из слота
Почему-то this.$slots.default[0].elm выводит undefined
arr1.forEach(function({ id }) {
if (this[id]) {
this[id].isAdded = true;
}
}, arr2.reduce((acc, n) => (acc[n.id] = n, acc), {}));
const newArr2 = arr2.map(function({ ...n }) {
if (this.has(n.id)) {
n.isAdded = true;
}
return n;
}, new Set(arr1.map(n => n.id)));
const text = 'определённый текст';
const link = document.querySelector(`a[href*="${text}"]`);
if (link) {
link.click();
}
class Parent extends React.Component {
state = {
count: 0,
}
onClick = () => {
this.setState(({ count }) => ({
count: count + 1,
}));
}
render() {
return (
<div>
<button onClick={this.onClick}>Добавить компонент</button>
{Array.from({ length: this.state.count }, () => <Input />)}
</div>
);
}
}
.click()
на [0].click()
или .get(0).click()
. const $filters = $('.filter').change(function() {
const filters = $filters
.get()
.filter(n => n.value)
.map(n => [ n.dataset.name, n.value ]);
$('.product')
.hide()
.filter((_, el) => filters.every(n => el.dataset[n[0]] === n[1]))
.show();
});
$link = mysqli_connect($host, $user, $pass, $db_name); ... $link = "https://td.com/topic-$zam2";
.modal-wrapper .open {
должно быть .modal-wrapper.open {
. 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('');
}
});