I'm working on a small project using Nuxt.js and I would like to know if there is any way to import some of my modules globally like
import $ from 'jquery'
import Swal from 'sweetalert2'
import toastr from 'toastr'
import Vue from 'vue'
Because each time I create a new page , I import the same modules . So I would like to know if there is any way to call this module in the boot for example.
In plugins
folder you could create a jquery.js
file and then in the nuxt.config.js
you could have it define it.
plugins: [
{
src: '~/plugins/jquery.js',
ssr:
}
]
Once you have defined it, you could use them in all your pages/components without invoking it repeatedly.
I hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.