尝试使用vuejs的按钮更新组件

时间:2018-08-02 07:14:45

标签: vue.js

我正在尝试使用一个按钮而不是两个按钮来更新组件,但是我不知道该怎么做

我的主要组件上都有这些按钮

<button @click="subnetp" type="button" class="btn btn-dark">Subnet</button>
<button @click="clear" type="button" class="btn btn-dark">Clear</button>

他们调用这些方法

 subnetp: function(){
      if(this.itsIp(this.ip.dec) && this.itsPrefix(this.ip.dec)){
        this.separete();
        this.showSubnet = true; 
        this.isReverse = false
      }
  },
  clear: function(){
    this.showSubnet = false;
    this.isReverse = true;
  }

单击“子网”按钮时,它将显示下一个组件并发送一些变量作为道具

 <subnet-app v-if="showSubnet" v-bind:ip='ip,host'></subnet-app>

如果我使用按钮更改组件中的信息,则必须首先单击清除按钮,然后单击子网以查看更新了信息的组件。

我只想用一个按钮来执行此操作,但是如果我尝试类似的操作并在子网方法中调用clear方法,则该按钮将不起作用,我仍然必须先单击clear

subnetp: function(){
      this.clear();
      if(this.itsIp(this.ip.dec) && this.itsPrefix(this.ip.dec)){
        this.separete();
        this.showSubnet = true; 
        this.isReverse = false
      }
  }

0 个答案:

没有答案