lue
🌱 Vue and vuex based library, writing less verbose code.
Installation
Install the pkg with npm:
npm install lue --save
or yarn
yarn add lue
Basic Uasage
1. create a module
// counter.js namespace: 'counter' state: count: 0 title: 'Counter' actions: { const val = statecount + 1; // should be return a object to update state // if return undefined or not a object, state won't be updated return count: val ; } { const val = statecount - 1; return count: val ; } ;
2. export all modules as a object
// modules/index.js;; counter other;
3. create vue router options
// options/index.jsconst App = import/* webpackChunkName: "app" */ 'path/to/app/index.vue';const Counter = import/* webpackChunkName: "counter" */ 'path/to/counter/index'; const Outer = template: '<router-view></router-view>' ; mode: 'history' routes: path: '/' component: Outer children: path: '' component: App path: 'counter' component: Counter // other config
4. create your app
;// path/to/index.js; ;;; // 1. install pluginVue; // 2. new a lue instanceconst app = ; // 3. create storeapp; // 4. init routerapp; // 5. start your applicationappstart'#app' // optional options object filters // env/vue-i18n.etc;
5. combine lue with vue components
<template> <div class="counter"> <h3>title:</h3> <div> <span class="decrease" @click="sub">-</span> <span>count</span> <span class="increase" @click="add">+</span> </div> </div></template> <script> ; computed: ... // or // ...mergeProps({ // test: 'counter.title', // }) methods: ... { this; } { this; } </script>
Lue Instance Properties
.store: Object
Vuex store instance.
.router: Object
Vue router instance.
.options: Object
Lue constructor options.
Lue Instance Methods
.createStore(modules: Object, opts?: Object)
Create vuex store. See opts.
.initRouter(routerOptions: Object)
Init vue-router instance. See routerOptions
.start(el: String, opts?: Object)
Start the app. See opts of creating a vue instance. el
is a css selector for document.querySelector
Examples
Running the examples:
npm install
npm run dev # serve examples at localhost:8000
LICENSE
MIT