版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
<!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>
<script src="./js/vue.js"></script>
</head>
<body>
<div id="app">
{{fullName}}
{{age}}
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
fName: 'Dell',
lName: 'Lee',
age: 28
},
computed:{
fullName: {
get: function(){
return this.fName +" " +this.lName;
},
set: function(value){
var arr = value.split(' ');
this.fName = arr[0];
this.lName = arr[1];
}
}
}
})
</script>
</body>
</html>