<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<p>{{ message }}</p>
<p>{{ getFullName() }}</p>
<p>{{ fullName }}</p>
</div>
<script>
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
firstName: "thomas",
lastName: "zhang",
},
methods: {
getFullName: function() {
return this.firstName + ' ' + this.lastName;
}
},
computed: {
fullName: function() {
return this.firstName + ' ' + this.lastName;
}
}
})
</script>
</body>
</html>
![](https://img2020.cnblogs.com/blog/1747317/202107/1747317-20210701101741708-1347545926.png)