Article directory
1. The cause of the problem
Because some browser versions are not compatible with
?.
syntax, you can use$$
it instead (as shown in the figure below), but for team collaboration to avoid?.
problems caused by troublesome use, you can use this (@babel/plugin-proposal-optional-chaining
) babel plugin to solve the problem.
2. Download and configure the plugin
first step
Download the plugin (@babel/plugin-proposal-optional-chaining).
npm install --save-dev @babel/plugin-proposal-optional-chaining
second step
The following code needs to be added to the project
babel.config.js
to expand the parser.
module.exports = {
presets: [
],
plugins:[
["@babel/plugin-proposal-optional-chaining"] //解析可选链式语法
]
}
third step
重启项目
, run configure.
ok