<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<h2>{{firstName + ' ' +lastName}}</h2>
<h2>{{firstName}} {{lastName}}</h2>
<h2>{{getFullName()}}</h2>
<h2>{{fullNmae}}</h2>
</div>
</body>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
firstName: 'liu',
lastName: 'jiep',
},
methods: {
getFullName() {
return this.firstName + ' ' + this.lastName
}
},
//计算属性,实质实现了get方法
computed: {
fullNmae() {
return this.firstName + ' ' + this.lastName
}
}
})
</script>
</html>
来源:CSDN
作者:小小小菜鸡zzzz
链接:https://blog.csdn.net/ojb98K/article/details/104125077