File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,25 @@ Now `VueWait` will use `Vuex` store for data management which can be traced in `
8383
8484<img src =" ./resources/vue-wait-2.gif " width =" 480 " >
8585
86+ ## ♻️ Usage with Nuxt.js
87+
88+ Add ` vue-wait/nuxt ` to modules section of ` nuxt.config.js `
89+
90+ ``` js
91+ {
92+ modules: [
93+ // Simple usage
94+ ' vue-wait/nuxt'
95+
96+ // Optionally passing options in module configuration
97+ [' vue-wait/nuxt' , { useVuex: true }]
98+ ],
99+
100+ // Optionally passing options in module top level configuration
101+ wait: { useVuex: true }
102+ }
103+ ```
104+
86105## 🔁 ` VueWait ` Options
87106
88107You can use this options for customize VueWait behavior.
Original file line number Diff line number Diff line change 1+ /*
2+ Nuxt.js module for vue-wait
3+
4+ Usage:
5+ - Install vue-wait package
6+ - Add this into your nuxt.config.js file:
7+ {
8+ modules: [
9+ // Simple usage
10+ 'vue-wait/nuxt'
11+
12+ // Optionally passing options in module configuration
13+ ['vue-wait/nuxt', { useVuex: true }]
14+ ],
15+
16+ // Optionally passing options in module top level configuration
17+ wait: { useVuex: true }
18+ }
19+ */
20+
21+ const { resolve} = require ( 'path' ) ;
22+
23+ module . exports = function nuxtVueWaitModule ( moduleOptions ) {
24+ const options = Object . assign ( { } , this . options . wait , moduleOptions ) ;
25+
26+ // Register plugin
27+ this . addPlugin ( {
28+ src : resolve ( __dirname , 'vue-wait-plugin.js' ) ,
29+ fileName : 'vue-wait-plugin.template.js' ,
30+ options : options
31+ } )
32+ } ;
33+
34+ // required by nuxt
35+ module . exports . meta = require ( '../package.json' ) ;
Original file line number Diff line number Diff line change 1+ import Vue from 'vue' ;
2+ import VueWait from 'vue-wait' ;
3+
4+ Vue . use ( VueWait ) ; // add VueLoading as Vue plugin
5+
6+ export default ( { app} ) => {
7+ // inject options from module
8+ const pluginOptions = [ < %= serialize ( options ) % > ] [ 0 ]
9+ app . wait = new VueWait ( pluginOptions )
10+ }
You can’t perform that action at this time.
0 commit comments