I am so confusing about Vue's structure. First time, I learnt from a video by freeCodeCamp channel on YouTube.
After that, I found a book to learn
Getting to Know Vue.js Learn to Build Single Page Applications in Vue from Scratch
by Brett Nelson
The problem I faced was that when I follow the tutorial on YouTube, I used unpkg
to run and it worked but with the book, they use
jsdelivr
and when I used the same code with the code I used for unpkg
, it didn’t work.
I have no idea about what I should learn because 2 tutorials from 2 sources I used were totally different.
Code I use for unpkg
<!DOCTYPE html>
<html>
<head>
<title>Vue 3</title>
</head>
<body>
<div id="app">
{{ propertyName }}
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
let app=Vue.createApp({
data: function(){
return {
propertyName: 'Hello from Getting to Know Vue.js!'
}
}
})
app.mount('#app')
</script>
</body>
</html>
Code I use for jsdelivr
(it works but doesn't work with the code in <script>
tag above):
<!DOCTYPE html>
<html>
<head>
<title>Vue 3</title>
</head>
<body>
<div id="app">
{{ propertyName }}
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
let app = new Vue({
el: '#app',
data: {
propertyName: 'Hello from Getting to Know Vue.js!'
}
});
</script>
</body>
</html>