javascript - The page always displays {{ message }}
巴扎黑
巴扎黑 2017-07-05 11:01:44
0
3
1029

Follow the tutorial on the official website, introduce <script src="https://unpkg.com/vue/dist/vu... and then directly copy the code from the official website to the local computer, as shown below

Why does {{message}} always appear on the web page?

Attached code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>test</title>
    <script type="text/javascript" src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<p id="app">
  {{ message }}
</p>
<script type="text/javascript">
    var app = new Vue({
        el: 'app',
        data: {
          message: 'Hello Vue!'
        }
    })
</script>
</body>
</html>
巴扎黑
巴扎黑

reply all(3)
曾经蜡笔没有小新

Didn’t you notice that the first script is missing a quotation mark? ?

刘奇

el: 'app' changed to el: '#app'

世界只因有你

Vue’s el attribute is a CSS selector, not an id name, as follows:

    var app = new Vue({
        // 修改目标元素为 #app 这一 CSS 选择器
        el: '#app',
        data: {
          message: 'Hello Vue!'
        }
    })
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template