<!DOCTYPE html>
<html>
<head>
<script src="http://192.168.1.22:8098"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body style="font-size: 30px">
<section id="app-2">
<button @click="welcome">Click => Chào mừng</button>
<!-- welcome là tên phương thức ta muốn gọi -->
</section>
<script>
new Vue({
el:'#app-2',
data:{
name:'Larave-VueJS'
},
//Đối tượng 'methods' là nơi định nghĩa các phương thức
methods:{
welcome: function(event){
//this ở đây là đối tượng Vue
alert('Xin chào ' + this.name + '!');
//event là sự kiện DOM native
if(event){
alert(event.target.tagName);
}
}
}
});
</script>
</body>
</html>