debian-mirror-gitlab/spec/frontend/helpers/keep_alive_component_helper.js
2021-01-30 21:13:32 +05:30

29 lines
635 B
JavaScript

import Vue from 'vue';
export function keepAlive(KeptAliveComponent) {
return Vue.extend({
components: {
KeptAliveComponent,
},
data() {
return {
view: 'KeptAliveComponent',
};
},
methods: {
async activate() {
this.view = 'KeptAliveComponent';
await this.$nextTick();
},
async deactivate() {
this.view = 'div';
await this.$nextTick();
},
async reactivate() {
await this.deactivate();
await this.activate();
},
},
template: `<keep-alive><component :is="view"></component></keep-alive>`,
});
}