(webpack4) how to configure jquery? in vue.config.js

databases depends on jquery, in vue project, so it needs to be introduced. In the past, it was introduced directly through CDN, but now the boss asked npm to introduce, npm install jQuery.
Direct import will report an error after checking and saying that my project is to configure webpack,. I can"t find the configuration of jquery in vue.config.js online. Thank you

.
Jun.18,2021

the problem is solved. This is what I wrote. I hope it will be helpful to the newcomers

.
        config.module
            .rule('expose1')
            .test(require.resolve('jquery'))
                .use()
                .loader('expose-loader')
                .options("jQuery")
                .end()
        config.module
            .rule('expose2')
            .test(require.resolve('jquery'))
                .use()
                .loader('expose-loader')
                .options("$")
                .end()

https://codeshelper.com/a/11.


check whether the jquery dependency name in package.json is correct, and confirm whether it is jQuery or jquery
webpack does not need to be changed, no problem

if it is jquery, then import 'jquery'


this does not need to be configured. After install, just import in


, the first article is too old. In the project generated by the new version of scaffolding, just define the dependency in package.json, install it, and then directly in .vue:

import $ from 'jquery'
In fact, what you need to consider later is whether to type in this dependency package. If you don't put it in externals
if it's my transformation, I suggest you not enter it. After all, it's not small, and to tell you the truth, it would be better to add a cdn address to script

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e489eb-44cca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e489eb-44cca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?