index.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link  type="text/css" rel="stylesheet" href="./main.css">
    <script src="https://unpkg.com/vue"></script>

    <title>Document</title>
</head>
<body>
<!--vue app是根容器-->
<div id="vue-app">
<!--数组下表获取-->
<!--    {{characters[0]}}-->
    <!---->
    <div id="bag" v-bind:class="{burst:ended}">
    </div>

    <div id="bag-health">
        <div v-bind:style="{width:health+'%'}"></div>
    </div>

    <div id="controls">
        <button v-on:click="punch" v-show="!ended">使劲敲</button>
        <button v-on:click="restart">开始</button>
    </div>
</div>
<script src="./app.js"></script>
</body>
</html>

main.js

new Vue({
    el:"#vue-app",
    data:{
    health:100,
        ended:false,
    },
    computed:{

    },
    methods:{
        punch:function (){
            this.health-=10
            if(this.health<=0){
                this.ended=true
            }
        },
        restart:function (){
            this.health=100
            this.ended=false
        }

     /*   updatexy(event){
            this.x=event.offsetX,
                this.y=event.offsetY
        },
        stopMoving(event){
            event.stopPropagation()
        }*/
    }
})

main.js

#bag{
    width:200px;
    height:500px;
    margin:0 auto;
    background:url(1.jpg) center no-repeat;
    background-size: 80%;
}
#bag.burst{
    background-image:url(2.jpg);

}
#bag-health{
    width: 200px;
    border:2px #000 solid;
    margin:0 auto 20px auto;
}
#bag-health div{
    height: 20px;
    background: crimson;
}
#controls{
    width: 200px;
    margin: 0 auto;
}

运行结果