Use top-level await in Vue to package the solution for error reporting

Error message

 error during build:
    Error: Transform failed with 1 error:
   assets/alarmStrategy-!~{00m}~.js:315:12: ERROR: Top-level await is not available in the    configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)

Solution: Add the following code in vite.config.js

export default defineConfig({
  plugins: [vue()],
  build:{
    target:['edge90','chrome90','firefox90','safari15']
  }
}

The main code packaging errors are added in build { } 

target: ['edge90', 'chrome90', 'firefox90', 'safari15'],
或者
build: {
    target: "es2019",
}
或者

build: {
    target: "esnext",
}

Guess you like

Origin blog.csdn.net/weixin_65478269/article/details/129879368
Recommended