为啥动态显示的名字就显示了undefined?
看不懂了昂,记录一下,慢慢理解吧
<!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>
新鲜刺激的东西永远都有,玩之前掂量掂量自己几斤几两