how to import internal global JS in nuxt.config.js

江枫思渺然 提交于 2019-12-11 05:15:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!