看不懂了昂,记录一下,慢慢理解吧
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue 示例</title> </head> <body> <div id="app" > 姓名:{{ fullName }} </div> <script src="https://unpkg.com/vue/dist/vue.min.js"></script> <script> var padDate = function(value){ return value < 10 ? '0' + value :value; } var app = new Vue({ el: '#app', data: { fistName: 'Jack', lastName: 'Green' }, computed: { fullName: { // Getter, 用于读取 get: function () { return this.fistName + ',' + this.lastName; }, // Setter,写入时触发 set: function (newValue) { var names = newValue.split(','); this.fistName = names[0]; this.lastName = names[names.length - 1]; } } } }) </script> </body> </html>