Vue use??

Using the ?? operator in Vue will report an error, because the ?? operator is a new syntax added to ECMAScript 2020 (ES2020), and Vue uses an older version of ECMAScript by default. Therefore, if you want to use the ?? operator in Vue, you need to ensure that your code runtime environment supports ES2020, and configure the relevant babel plugin in the Vue project.

Specifically, you can install the ** @babel/plugin-proposal-nullish-coalescing-operator ** plug-in in the project and configure it in the babel configuration file. The example is as follows:

  1. install plugin
npm install --save-dev @babel/plugin-proposal-nullish-coalescing-operator
  1. Configure the .babelrc file
{
    
    
  "plugins": ["@babel/plugin-proposal-nullish-coalescing-operator"]
}

Guess you like

Origin blog.csdn.net/weixin_43989656/article/details/129487620