代码之家  ›  专栏  ›  技术社区  ›  Sid Heart

在vue中触发false到true

  •  0
  • Sid Heart  · 技术社区  · 7 年前

    我使用的是laravel 5.6,我正在尝试将提交按钮微调器的false项设置为true。

    我的表格是这样的:

    <template>
    <form aria-label="Register" @submit.prevent="hit()">
    <button type="submit" class="btn btn-primary">
       <i class="fa fa-circle-o-notch fa-spin" v-if="spin"></i> Register
    </button>
    </template>
    

    我补充说 v-if="spin" :

    <script>
    data(){
       return{
         spin:false    
       }
    },
    methods:{
     hit(){
      spin = true
    }
    </script>
    

    请帮帮我。

    2 回复  |  直到 7 年前
        1
  •  2
  •   Sergeon    7 年前

    spin 是组件的成员,因此您需要从 this

    methods:{
      hit(){
        this.spin = true
    }
    
        2
  •  2
  •   Ghyath Darwish    7 年前

    你必须设定 this 引用它:

    methods:{
      hit(){
        this.spin = true
      }
    

    推荐文章