问题
How do I add a global JS file to the nuxt config?
module.exports = {
/*
** Global CSS
*/
css: ['~/assets/css/main.css'],
/*
** Global JS
*/
js: ['~/assets/js/main.js']
}
It does not work obviously.
any ideas?
回答1:
Simply keep your script.js file into static folder, because static folder treat as root folder.
and change nuxt.config.js configuration file like below
module.exports = {
//Global JS
script: [
{ src: '/script.js'}
]
........
..........
}
you can see another solution from here
来源:https://stackoverflow.com/questions/56072331/how-to-import-internal-global-js-in-nuxt-config-js