debian-mirror-gitlab/spec/frontend/helpers/keep_alive_component_helper.js

30 lines
635 B
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
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>`,
});
}