<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>监听</title>
</head>
<body>
    <div id="app">
        <input type="number" v-model="length">
        <p>{{area}}</p>
    </div>

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

    <script>
        let square = {
            length:2,
            area:4
        };

        let vm = new Vue({
            el:'#app',
            data:square,
            watch:{
                length: function (value) {
                    this.area = value * value;
                    console.log(vm.area);
                }
            }
        })

        console.log(vm.area);
    </script>
</body>
</html>