エラーのスクリーンショット:
エラー分析:
クロスオリジン リクエストは、http、data、chrome、chrome-extension、chrome-untrusted、https のプロトコル スキームのみをサポートします。
解決:
1. プロジェクトをサーバーにデプロイする
2. vscode にプラグインをインストールするLive Server
html ファイルを右クリックして開きます。
その他: vue-cli5 より前のバージョンでは、オプションがvue.config.js
で構成されている限り、パッケージ化されたプロジェクトをローカルで開くことができますが、vue-cli5 では無効です。publicPath
パッケージ化されたファイルを表示した後、vue-cli5 によってパッケージ化された index.html が以下を使用していることがわかりましたES Module
。
<!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>
type="module"
2つのスクリプトによって引き起こされる問題です