debian-mirror-gitlab/app/assets/javascripts/nav/mount.js

30 lines
649 B
JavaScript
Raw Normal View History

2021-06-08 01:23:25 +05:30
import Vue from 'vue';
import Vuex from 'vuex';
2021-09-04 01:27:46 +05:30
import ResponsiveApp from './components/responsive_app.vue';
2021-06-08 01:23:25 +05:30
import App from './components/top_nav_app.vue';
import { createStore } from './stores';
Vue.use(Vuex);
2021-09-04 01:27:46 +05:30
const mount = (el, Component) => {
2021-06-08 01:23:25 +05:30
const viewModel = JSON.parse(el.dataset.viewModel);
const store = createStore();
return new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'TopNavRoot',
2021-06-08 01:23:25 +05:30
store,
render(h) {
2021-09-04 01:27:46 +05:30
return h(Component, {
2021-06-08 01:23:25 +05:30
props: {
navData: viewModel,
},
});
},
});
};
2021-09-04 01:27:46 +05:30
export const mountTopNav = (el) => mount(el, App);
export const mountTopNavResponsive = (el) => mount(el, ResponsiveApp);