<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>演示计算属性setter</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="firstName">
        <input type="text" v-model="lastName">
        <input type="text" v-model="fullName">
    </div>

    <script src="../js/vue.js"></script>

    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                firstName :'Foo',
                lastName:'Bar',
                //fullName: '', //错误,不能加
            },
            computed:{
                fullName:{
                    get:function () {
                        return this.firstName + ' ' + this.lastName
                    },
                    set:function (newValue) {
                        let names = newValue.splice(' ');
                        this.firstName = names[0];
                        this.lastName = names[names.length -1];
                    }
                }
            }
        })
    </script>
</body>
</html>