'Vue template not work while using es6 import vue

Below is my reproduce step:

  1. npm install [email protected]

  2. write below code in my main.js file

    import Vue from 'vue' new Vue({ el: '#app', data: { msg: 'hello,word' } })

  3. use webpack build it, then it will build a file in dist folder

  4. then I write index.html file

<!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><span id="app">{{ msg }}</span></div>
  </div>
  <script src="./dist/main.js"></script>
</body>
</html>

then I open the index.html file in chrome, but it not display 'hello, word', I am a new beginner vue, I can not figure out what it wrong. thanks in advance.enter image description here

enter image description here

And I alse found that vue delete my dom like above img.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source