简单的HTML与vue.js无法正常工作

问题描述:

vue.js的初学者和我关注此链接:
https://www.sitepoint.com/getting-started-with-vue-js/

A beginner of vue.js and I followed this link: https://www.sitepoint.com/getting-started-with-vue-js/

几乎将代码复制到我的html中。但是它只是没有工作。有人可以帮我找到出错的地方吗?


以下是所有代码:

Almost copy the code into my html.However it just not working.Can someone help me find what is going wrong?
Here are all the codes:

<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js">
</script>

<script>

var myModel = {
  name: "Ashley",
  age: 24
};

var myViewModel = new Vue({
  el: '#my_view',
  data: myModel
});

</script>
<div id="my_view">
{{ name }}
</div>
</body>
</html>

结果只是: {{name}}

您需要添加< head> 标签并在文件末尾添加脚本,如下所示:

You need to add the <head> tag and add the script at the end of the file like this:

<html>
<head>
<title></title>
</head>
<body>
<div id="my_view">
{{ name }} {{ age }}
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>

<script>

var myModel = {
  name: "Ashley",
  age: 24
};

var myViewModel = new Vue({
  el: '#my_view',
  data: myModel
});

</script>

</body>
</html>