VueCLI5.X version build project (package) open locally and report an error

Error screenshot:
insert image description here
error analysis:

Cross-origin requests only support protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

solution:

1. Deploy the project to the server
2. Install the plugin in vscodeLive Server

insert image description here
Right click on the html file to open:
insert image description here

Others : In versions prior to vue-cli5, the packaged project can be opened locally, as long as the optionvue.config.js is configured in , but it is invalid in vue-cli5. publicPathAfter viewing the packaged file, I found that the index.html packaged by vue-cli5 uses ES Module:
insert image description here

<!doctype html>
<html lang="">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
  <link rel="icon" href="favicon.ico">
  <title>construct-zp</title>
  <script defer="defer" type="module" src="static/js/chunk-vendors.be7cdae2.js"></script>
  <script defer="defer" type="module" src="static/js/app.1d00b639.js"></script>
  <link href="static/css/chunk-vendors.3dcf1cd1.css" rel="stylesheet">
  <link href="static/css/app.9e5a03a7.css" rel="stylesheet">
  <script defer="defer" src="static/js/chunk-vendors-legacy.e1baa594.js" nomodule></script>
  <script defer="defer" src="static/js/app-legacy.b9d309ea.js" nomodule></script>
</head>

<body><noscript><strong>We're sorry but construct-zp doesn't work properly without JavaScript enabled. Please enable it
      to continue.</strong></noscript>
  <div id="app"></div>
</body>

</html>

It type="module"is the problem caused by the two scripts

Guess you like

Origin blog.csdn.net/sunddy_x/article/details/124964399