There is a picture. After react is defined with the arrow function in the class, the compilation error is reported. Is it the babel configuration problem?

the following three pictures. When npm run dev, syntax errors are reported. Is it a problem with babel configuration?
is mainly because when you want to define a function, you don"t want to use bind, so change it to the arrow function, but always report an error.


May.04,2022

package.json
"@ babel/plugin-proposal-class-properties": "^ 7.0.0",

webapck

"plugins": ['@babel/plugin-proposal-class-properties']

found a solution. I just went to the console of the browser and saw a paragraph

.
syntax 'classProperties' isn't currently enabled

so do a search and install

npm i -D @babel/plugin-proposal-class-properties

then in webpack, configure

under babel-load
options: {
        plugins: ['@babel/plugin-proposal-class-properties']
         }

Source
https://www.cnblogs.com/52tec...

Menu