vueゲームケース

2557 ワード

最終的な効果:
game.vueのすべてのコード:



    export default {
        name: "game",
      data(){
          return{
            health: 100,
            ended: false
          }
      },
      methods: {
        blow: function(){
          this.health -= 10;
          if(this.health <= 0){
            this.ended = true;
            this.health = 0
          }
          // console.log(this.health,this.ended)
        },
        restart: function(){
          this.health = 100;
          this.ended = false;
          // console.log(this.health,this.ended)
        }
      }
    }