javascript - The path to the correct path is introduced in react but an error is reported
漂亮男人
漂亮男人 2017-06-26 10:57:05
0
5
891

The jQuery file was introduced correctly, but an error was reported after compilation. Please give an answer from an experienced driver.

漂亮男人
漂亮男人

reply all(5)
迷茫

If you download it with npm, you can directly use import $ from 'jquery'.
If you downloaded the library manually, you can try var $ = require('jquery path').
If you have to use import to introduce it, then open the jquery library and manually set export at the bottom of the closure to export jquery

学习ing

Since they are all introduced globally.

<script src="jquery.js"></script>

Is there any difference?

Introducing jq into react, what is your starting point? . .

世界只因有你

1. export(module.export) and import

ES6 module mainly has two functions: export and import
export is used to export the interface of variables of this module (a file can be understood as a module)
import is used to load another module containing the export interface in a module.
That is to say, after using the export command to define the external interface of the module, other JS files can load this module (file) through the import command.
So please check whether jquery supports export or module.export.

2. Install jQuery package directly

3. For error message, you can refer to this: https://stackoverflow.com/que...

某草草
module.exports = {
    resolve: {
        alias: {
            $: " 你的jquery路径"
        }
    }
};
習慣沉默

Your package is not a standard npm package. It is recommended that you use npm to install jQuery and then use

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template