data() {
return {
dates: [ массив допустимых дат, в числовом виде (количество миллисекунд) ],
disabledFn: {
customPredictor: date => !this.dates.includes(new Date(date).setHours(0, 0, 0, 0)),
},
};
},
<datepicker :disabledDates="disabledFn" />
присваивание всем переменным, которые используются в компоненте, их дефолтное значение мне тоже кажется не лучшей идеей
GET_CHARACTERS
? Не вижу. Надо добавить.let data = await axios.get(baseURL); context.commit('SET_CHARACTERS', data)
const response = await axios.get(baseURL);
context.commit('SET_CHARACTERS', response.data.results);
<div>{{ $store.state.characters }}</div>
<div v-for="n in $store.state.characters">
{{ n.name }}
</div>
('ic' + true) ? 'on' : ('off' + '.svg')
computed: {
className() {
return условие ? 'icon.svg' : 'icoff.svg';
},
...
<p :class="className">
computed: {
stationsWithCars() {
return this.cars.reduce(
(acc, n) => (acc[n.address]?.cars.push(n), acc),
Object.fromEntries(this.stations.map(n => [ n.name, { station: n, cars: [] } ]))
);
},
},
<div v-for="{ station, cars } in stationsWithCars" :key="station.id">
<h1>{{ station.name }}</h1>
<ul>
<li v-for="car in cars" :key="car.id">{{ car.name }}</li>
</ul>
</div>
v-for="area in `${ this.$route.params.type }Areas`"
v-for="area in this[`${$route.params.type}Areas`]"
разве vue не повсеместно лишает возможности мутировать данные родителя в потомках?
как вообще так вышло, что v-model внизу сумел изменить serviceBlocksBlocks
data: () => ({
items: [ 1, 25, 32, 4, 5 ],
filter: false,
}),
computed: {
filteredItems() {
return this.items.filter(n => n < 10);
},
},
<label>
<input type="checkbox" v-model="filter">
Фильтровать
</label>
<ul>
<li v-for="n in (filter ? filteredItems : items)">{{ n }}</li>
</ul>
Я не меняю prop href
@Prop(String) href = '';
It's not supported to define eachdefault
property like@Prop() prop = 'default value'
.
metricsColumn: true
.computed: {
metricsColumns() {
return this.headers.filter(n => n.metricsColumn);
},
},
<template
v-for="(n, i) in metricsColumns"
#[`item.${n.value}`]="{ item: { metrics: { [i]: item } } }"
>
<v-chip
:color="colors[item.metricsValueMarkName]"
:key="n.value"
dark
>
{{ item.metricsValue }}
</v-chip>
</template>
:style="mapStyles"
data() { return { mapStyles: { styles: [
mapStyles: {
на options: {
:style="mapStyles"
на :options="options"
data: () => ({
contact: '',
}),
methods: {
onClick() {
if (this.contact) {
this.$emit('close');
}
},
},
<input v-model="contact">
<button @click="onClick">