根据复选框禁用

时间:2019-07-15 14:22:32

标签: javascript vue.js

所以我有一个声明为true的复选框,因此可以对其进行检查,想法是当我取消选中该复选框时我需要将其禁用,我该怎么做?我有这样的东西

<el-checkbox v-model="form.agentBoolean" style="padding-top: 45px; float: left">
   Selectează
</el-checkbox>

<app-typeahead :md="12" :sm="8" v-model="form.trader" :fetch-suggestions="queryAgent" 
    :disabled="agentBoolean === false" prop="trader" label="Agent" @select="setTrader">
     <template slot="item-template" slot-scope="{ item }">
          <div class="typeahead-value">{{ item.partnerName }} </div>
          <div class="typeahead-info">
              <b>Eori:</b> {{ item.partnerEori }} <br>
              <b>Tara:</b> {{ item.countryName }}
          </div>
      </template>
</app-typeahead>

我在数据中声明了它

form: {
        agentBoolean: true,
        operatorBoolean: true
      }

我想做一个观察者,但我真的不知道该如何处理

watch: {
    'form.agentBoolean': function(newVal, oldVal) {
      if (this.form.agentBoolean === false) {
        this.form.owner.disabled = true
        return
      }
    }
  }

0 个答案:

没有答案