Vue.之. 動態設置按鈕Disabled
按鈕代碼如下:
添加了一個 屬性 :disabled="isAble" ,控制:更新按鈕、重置按鈕
1 <el-form-item> 2 <el-button type="primary" :disabled="isAble" @click="operateFormSubmit()" plain> 更 新 </el-button> 3 <el-button :disabled="isAble" @click="operateFormSubmitReset('operateForm')" > 重 置 </el-button> 4 <el-button type="success" @click="operateFormAppend()" plain> 追加 </el-button> 5 </el-form-item>
在Vue的代碼中,如下:
operateFormRemovedomain 是一個方法。主要代碼是:this.isAble = true 這個控制上面按鈕可用不可用.
operateFormRemoveDomain(item) { let domains = this.operateForm.domains let _len = domains['length'] - 1 if (_len == 0) { this.isAble = true; } else { this.isAble = false; } var index = this.operateForm.domains.indexOf(item) if (index !== -1) { this.operateForm.domains.splice(index, 1) } },