<!DOCTYPE html>
<html>

<head>
    <meta charset='utf-8'>
    <title></title>
    <script src='../js/vue.js'></script>
</head>

<body>
    <div id='app'>
        姓: <input type="text" placeholder="First Name" v-model="firstName"><br>
        名: <input type="text" placeholder="Last Name" v-model="lastName"><br>
        姓名: <input type="text" placeholder="Full Name1" v-model="fullName"><br>
    </div>
    <script>
        new Vue({
            el: '#app',
            data: {
                firstName: 'A',
                lastName:"B",
                fullName:""
            },
            watch:{
                firstName:{
                    handler(value){
                        // setTimeout(()=>{
                            this.fullName = value +"-"+this.lastName
                        // },10000)
                    },
                    immediate:true //初始化异步代码立即执行
                }
            }
        })
    </script>
</body>

</html>
posted on 2021-07-07 20:29  文种玉  阅读(772)  评论(0编辑  收藏  举报