报错的代码是这样的
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<script src="/bundle.js"></script>
<body>
<div>
<div id="app"></div>
</div>
</body>
</html>
解决:将<script src="/bundle.js"></script>
放在body
标签后面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>
<div id="app"></div>
</div>
</body>
<script src="/bundle.js"></script>
</html>