data: () => ({
sortBy: '',
...
}),
<v-btn @click="sortBy = 'имя_свойства_по_которому_надо_выполнить_сортировку'">click me</v-btn>
<v-data-table :sort-by.sync="sortBy">...</v-data-table>
data: () => ({
sortBy: [],
sortDesc: [],
...
}),
methods: {
sort(colName) {
const sameCol = this.sortBy[0] === colName;
const sortDesc = this.sortDesc[0];
this.sortBy = sameCol && sortDesc ? [] : [ colName ];
this.sortDesc = sameCol && sortDesc ? [] : [ sameCol ];
},
...
},
<v-btn @click="sort('имя_свойства_по_которому_надо_выполнить_сортировку')">click me</v-btn>
<v-data-table :sort-by.sync="sortBy" :sort-desc.sync="sortDesc">...</v-data-table>
sort(colName) {
const index = this.sortBy.indexOf(colName);
if (index === -1) {
this.sortBy.push(colName);
this.sortDesc.push(false);
} else if (this.sortDesc[index]) {
this.sortBy.splice(index, 1);
this.sortDesc.splice(index, 1);
} else {
this.$set(this.sortDesc, index, true);
}
},
<v-btn @click="sort('имя_свойства_по_которому_надо_выполнить_сортировку')">click me</v-btn>
<v-data-table ref="table">...</v-data-table>
methods: {
sort(colName) {
const index = this.свойство_описывающее_столбцы_таблицы.findIndex(n => n.value === colName);
this.$refs.table.$el.querySelector('thead tr').cells[index].click();
},
...
},
import { yandexMap, ymapMarker, loadYmap } from 'vue-yandex-maps';
components: {
yandexMap,
ymapMarker,
},
data: () => ({
coords: null,
markers: [],
settings: { /* ... */ },
}),
methods: {
onClick(e) {
this.markers.push({
id: 1 + Math.max(0, ...this.markers.map(n => n.id)),
coords: e.get('coords'),
});
},
},
async mounted() {
await loadYmap({ ...this.settings, debug: true });
ymaps.geolocation.get().then(res => {
this.coords = res.geoObjects.position;
});
},
<yandex-map
v-if="coords"
:coords="coords"
@click="onClick"
>
<ymap-marker
v-for="n in markers"
:key="n.id"
:marker-id="n.id"
:coords="n.coords"
></ymap-marker>
</yandex-map>
data: () => ({
items: [ ... ],
active: null,
}),
<v-xxx
v-for="(n, i) in items"
:показыватьДополнительныйКонтент="active === i"
@переключитьОтображениеДополнительногоКонтента="active = active === i ? null : i"
...
const xxx = Vue.observable({ active: null });
computed: {
показыватьДополнительныйКонтент() {
return xxx.active === this.какоеТоСвойствоСУникальнымЗначением;
},
},
<div v-if="показыватьДополнительныйКонтент">
...
</div>
methods: {
переключитьОтображениеДополнительногоКонтента() {
xxx.active = this.показыватьДополнительныйКонтент
? null
: this.какоеТоСвойствоСУникальнымЗначением;
},
},
<button @click="переключитьОтображениеДополнительногоКонтента">
{{ показыватьДополнительныйКонтент ? 'hide' : 'show' }}
</button>
false
, тогда ничего не делаете, по умолчанию будет отрендерен чекбокс, если true
- передаёте в соответствующий слот что там вам надо:data: () => ({
событиеНаступило: false,
...
}),
@событие="событиеНаступило = true"
<v-data-table>
<template v-if="событиеНаступило" #item.data-table-select>
здесь размещаете контент, который должен отображаться вместо чекбоксов
</template>
...
<v-data-table>
<template #item.data-table-select="{ item, isSelected, select }">
<div v-if="item.событиеНаступило">hello, world!!</div>
<v-simple-checkbox
v-else
:value="isSelected"
@input="select($event)"
></v-simple-checkbox>
</template>
...
v-model="dialog_destroy"
), то при открытии любого из них открываются все и вы всегда видите только последний - он скрывает собой остальные.data: () => ({
showDialog: {},
...
}),
<v-dialog v-model="showDialog[item.свойствоИмеющееУникальныеЗначенияДляКаждогоItem]">
<v-btn @click="showDialog[item.свойствоИмеющееУникальныеЗначенияДляКаждогоItem] = false">Отменить
<v-dialog v-model="item.showDialog">
<v-btn @click="item.showDialog = false">Отменить
data: () => ({
dialogData: null,
...
}),
<v-data-table>
<template #item.action="{ item }">
<v-btn @click="dialogData = item">Удалить контакт</v-btn>
</template>
</v-data-table>
<v-dialog :value="!!dialogData" @input="dialogData = $event">
<span>Удалить контакт: @{{ dialogData?.contact_name }}</span>
<v-btn :href="dialogData?.destroy_link">Подтвердить</v-btn>
<v-btn @click="dialogData = null">Отменить</v-btn>
</v-dialog>
functional: true,
render(h, ctx) {
return h('div', {
class: 'col-12',
}, [
h('input', {
class: [ ctx.data.class, ctx.data.staticClass ],
}),
]);
},
mounted() {
this.$el.querySelectorAll('input').forEach(n => n.dispatchEvent(new Event('input')));
},
inheritAttrs: false,
model: {
prop: 'checked',
},
props: [ 'value', 'checked' ],
computed: {
innerChecked: {
get() {
return this.checked;
},
set(val) {
this.$emit('input', val);
},
},
},
<label>
<input
type="checkbox"
v-model="innerChecked"
v-bind="$attrs"
:value="value"
>
<slot></slot>
</label>
data: () => ({
items: [
{ label: 'hello, world!!', value: 69 },
{ label: 'fuck the world', value: 187 },
{ label: 'fuck everything', value: 666 },
],
checked: [ 187 ],
}),
watch: {
checked(val) {
if (val.length > 1) {
this.checked = val.slice(-1);
}
},
},
<v-checkbox
v-for="n in items"
v-model="checked"
:value="n.value"
name="items[]"
>
{{ n.label }}
</v-checkbox>
data: () => ({
closing: false,
}),
<template>
<div
@mousedown="closing = $event.target === $el"
@mouseup.self="closing && close()"
>
...
methods: {
classes: obj => ({
'current-active': obj.progress.current > 0,
}),
...
},
:class="classes(cutLine)"
routes: [
{
...
meta: { pageTitle: 'hello, world!!' },
},
{
...
meta: { pageTitle: 'fuck the world' },
},
...
],
<div>{{ $route.meta.pageTitle }}</div>
methods: {
marked: (text, search) => search
? text.replace(RegExp(search.replace(/[\\^$|.*?+{}()[\]]/g, '\\$&'), 'gi'), '<mark>$&</mark>')
: text,
},
<div v-html="marked(text, search)"></div>