Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
134
rated 0 times [  135] [ 1]  / answers: 1 / hits: 27873  / 8 Years ago, fri, january 20, 2017, 12:00:00

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



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>


The result is just:{{name}}


More From » vue.js

 Answers
7

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>

[#59278] Wednesday, January 18, 2017, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
davism

Total Points: 339
Total Questions: 100
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;