myMap.enterFullscreen()
var myMap = new ymaps.Map('map', {
<div ref="map"></div>
mounted() {
ymaps.ready(() => {
this.map = new ymaps.Map(this.$refs.map, {
...
когда нажимаю на другой блок, то цвет кнопки не становится прежним
transition: background 9999999s;
:active
вы, очевидно, не разобрались.:checked
. state = {
value: 0,
options: [ 'Не отмечено', 'Отмечено' ],
}
onChange = ({ target: t }) => {
this.setState(() => ({
value: +t[t.dataset.stateAttr],
}));
}
render() {
const { value, options } = this.state;
return (
<div>
<select
value={value}
onChange={this.onChange}
data-state-attr="value"
>
{options.map((n, i) => <option value={i}>{n}</option>)}
</select>
<br />
<label>
<input
type="checkbox"
checked={value}
onChange={this.onChange}
data-state-attr="checked"
/>
{options[value]}
</label>
</div>
);
}
const longestStr = arr.reduce((max, n) => max.length > n.length ? max : n, '');
// или
const longestStr = arr.sort((a, b) => b.length - a.length)[0];
// или
const longestStr = arr.reduce((acc, n) => (acc[n.length] = n, acc), []).pop();
function max(data, key = n => n) {
const getVal = key instanceof Function ? key : n => n[key];
let result = null;
for (const n of data) {
const val = getVal(n);
if (!result || result[1] < val) {
result = [ n, val ];
}
}
return result?.[0];
}
const longestStr = max(arr, 'length');
data: () => ({
status: '',
...
computed: {
statuses() {
return [...new Set(this.characters.map(n => n.status))];
},
...
<select v-model="status">
<option value="">< ALL ></option>
<option v-for="n in statuses">{{ n }}</option>
</select>
computed: {
filteredCharacters() {
const search = this.search.toLowerCase();
const status = this.status;
return this.characters.filter(n => (
(!search || n.name.toLowerCase().includes(search)) &&
(!status || status === n.status)
));
},
...
const getRepetition = (arr, repeated) => Array
.from(arr.reduce((acc, n) => acc.set(n, -~acc.get(n)), new Map))
.reduce((acc, n) => (n[1] === repeated && acc.push(n[0]), acc), []);
function getRepetition(arr, repeated) {
const result = [];
const count = {};
for (const n of arr) {
if (!count.hasOwnProperty(n)) {
count[n] = 0;
}
count[n]++;
}
for (const n in count) {
if (count[n] === repeated) {
result.push(+n);
}
}
return result;
}
data: () => ({
map: {
activeMarkerIndex: null,
markerIconImages: [ MAP_MARKER_DEFAULT, MAP_MARKER_ACTIVE ],
...
<ymap-marker
v-for="(n, i) in markers"
:icon="{
...map.markerIcon,
imageHref: map.markerIconImages[+(map.activeMarkerIndex === i)],
}"
@mouseenter="map.activeMarkerIndex = i"
@mouseleave="map.activeMarkerIndex = null"
...
<li
v-for="(n, i) in objects"
@mouseenter="map.activeMarkerIndex = i"
@mouseleave="map.activeMarkerIndex = null"
...
$(document).click('.e-1', function(event) { console.log(event.target) });
$(document).on('click', '.e-1', function(e) {
console.log(e.currentTarget);
});
updated() { this.$refs.scroll.addEventListener('wheel', this.fadeOut); },
v-if
ложно, элемента нет. Соответственно, в $refs.scroll
вместо ссылки на несуществующий элемент пишется null
, и вы пытаетесь обратиться к свойству этого null
, чего делать не следует - у null
никаких свойств нет и быть не может, подобные обращения заканчиваются ошибками вот как та, что получили вы.