1

Holla, first of all thanks to those who are answering to this question. this question might be silly to ask. i am switching my spa from vue.js to nuxt provided by vue.js but write now i am in trobule beacuse of 0% visiblity between how whole nuxt works.

Question:

  1. how to register global component.
  2. how to switch layouts in nuxt on certain user of client-side behaviour.
  3. where to write vue.use(someplugin).
  4. how to write middle ware export of method which connects to server with user ip deatils than load page.
  5. how to deal with enviornment variables in vue.js
  6. how to transfer data from any middle ware and plugin to components which i am using.
  7. is there any way to seperate vue component and there respective methods and data.

CURRENT PROBLEM DUE TO WHICH I HAVE NO WAY TO PROCEED ON MY PROJECT

Registering modules using vue.use(plugins) in ~plugins/registerPlugin.js ex:

    'use strict';

    /*
    MODULE IMPORTS
    */

    // npm modules.
    import Vue from 'vue';

    // temp modules. ex modules for registration.
    import __vueCookie from 'vue-cookies'; // npm: provide cookie set and get.
    import __veeValidate from 'vee-validate'; // npm: provide field validation.
    import __moment from "vue-moment"; // npm: filter plugin for vue.js.
    import __vueLocalStorage from 'vue-localstorage'; // npm: provide local storage api.
    import __vueSessionStorage from 'vue-session'; // npm: module for managing session storage.
    import __vueResource from 'vue-resource'; // npm: vue resource library.


    /*
     PLUGIN REGISTRATION
    */

    // use vue resource library.
    Vue.use(__vueResource);

    // vue validate for input validation.
    Vue.use(__veeValidate);

    // vue filter plugin for date and time.
    Vue.use(__moment);

    // cookie plugin manager for vue.
    Vue.use(__vueCookie);

    // local storeAge manager for vue.
    Vue.use(__vueLocalStorage);

    // session storage manager for vue.
    Vue.use(__vueSessionStorage);
1
  • I would suggest reading the entire guide on the Nuxt website before you start. I think a lot of your questions are answered there: nuxtjs.org/guide Commented Dec 30, 2017 at 6:54

1 Answer 1

1

Here my answers for questions 1-5. 6 and 7 are not completely clear to me. Perhaps you would like to rewrite them?

how to register global component.

Make a plugin file in /plugins and then add it in nuxt.config.js

plugins: ['~/plugins/components.js']

Have a look here.

how to switch layouts in nuxt on certain user of client-side behaviour.

Have a look into this discussion

where to write vue.use(someplugin)

You would add them as a "nuxt" plugin and add them also in nuxt.config.js. Have a look here how to do it.

how to deal with enviornment variables in vue.js

You set them also in nuxt.config.js. See here.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks sir for reply can you tell me where to place methods which are repeated in components and is static folder good for containing configuration file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.