<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>

<body>
    <div id="app">
        主角团：
        <div v-for="(i,j) in arr">{{i.name}}  {{j}}</div>

        <input type="text" v-model="shuru" />
        {{shuru}}

        <div>
            {{num1}}  {{num2}}
        </div>
        <div>sum:{{sum}}</div>

        <div>
            {{ beforechange}}
        </div>

        <button @click="change">change</button>
    </div>
    <script>
        var app = new Vue({
            el: '#app',   //绑定html元素的标志
            data: {
              arr:[{name:"ruby"},{name:"weiss"},{name:"blake"},{name:"yang"}],
              shuru:"",
              num1:1,
              num2:2,
              beforechange:"0.0"
            },
            methods:{
                change:function(){
                    this.beforechange="101"
                }
            },
            computed:{
                sum:function(){
                    return this.num1+this.num2
                }
            },
            watch:{
                beforechange:function(){
                    console.log("ruby")
                }
            }
            
        })
    </script>
</body>

</html>