fanhualuojin154873
fanhualuojin154873

Reputation: 541

Vue.js template do not shows the data

In the Vue.js Document:

I test text data binding like bellow:

var vm = new Vue({
  el: '#app',
  data: {
    msg: "abc"
  }

})
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>


</head>
<body>

<div id="app">
  this will never change:{{* msg }}
</div>

<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.5.13/vue.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/vue-resource/1.3.4/vue-resource.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</body>
</html>

But there do not shows the msg. why I can not get it?

Upvotes: 0

Views: 24

Answers (1)

aircraft
aircraft

Reputation: 26924

You document version is 1.x, and you use the vue.js CDN version is 2.5.13:

<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.5.13/vue.min.js"></script>

The {{* }} syntax is removed in Vue 2.x, you can use v-once to replace it:

<div id="app" v-once>
  this will never change:{{ msg }}
</div>

Upvotes: 2

Related Questions