vue cli nullish uses ?? or ?. Unexpected token error occurs

Error description

An Unexpected token error occurred when packaging and compiling the vue cli project.

The error is ??syntax.

try solution

Is it a compile error for ts?

https://stackoverflow.com/questions/58813176/webpack-cant-compile-ts-3-7-optional-chaining-nullish-coalescing

Whether the preset
https://github.com/vuejs/vue-cli/pull/6459/files is not triggered

  "browserslist": [
    "samsung 12.0"
  ],

works for me

// babel.config.js
module.exports = {
  presets: [
    [
      '@vue/app',
      {
        polyfills: ['es.promise', 'es.symbol']
      }
    ]
  ],
  plugins: [
    '@babel/plugin-proposal-nullish-coalescing-operator',
    '@babel/plugin-proposal-optional-chaining',
  ],
}

Add two plugins to babel

Guess you like

Origin blog.csdn.net/weixin_48408736/article/details/120493307