1.0.0 • Published 4 years ago

vue-smart-modules v1.0.0

Weekly downloads
2
License
BSD-3-Clause
Repository
github
Last release
4 years ago

vue-smart-modules

This is a simple plugin for dynamic registration of modules (with internal store and routes).

Install

With yarn:

yarn add vue-smart-modules

With npm:

npm i vue-smart-modules

Then, register VueModules in your app entry point (also register router and store in VueModules options):

import Vue from 'vue'
import VueModules from 'vue-smart-modules'
import router from './router'
import store from './store'

Vue.use(VueModules, { store, router })

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

Usage

Create the directory @/src/modules and create the module directory inside (foo for example). Then, create index.js with following contents:

import store from './store'
import routes from './routes'

export default {
  store,
  routes
}

Example contents of store.js (it will be namespaced store with the same name as module):

export default {
  namespaced: true,
  state: {}
}

Example contents of routes.js:

import Foo from './components/Foo.vue'

export default [
  {
    path: '/foo',
    component: Foo
  }
]