Cannot find element: #app

493 阅读1分钟

@TOC

使用webpack 搭建 vue,遇到这个问题: Cannot find element: #app

解决办法:

1,根目录public,新建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><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

2,webpack.config.js

...
plugins: [
    new HtmlWebpackPlugin({
      title: "webpack & vue",
      template: "./public/index.html",
    }),
  ],
...