To remove the disabled prop, you should set its value to false
.(要删除禁用的道具,应将其值设置为false
。)
This needs to be the boolean value for false
, not the string 'false'
.(这需要是false
的布尔值,而不是字符串'false'
。)
So, if the value for validated
is either a 1 or a 0, then conditionally set the disabled
prop based off that value.(因此,如果已validated
的值是1或0,则根据该值有条件地设置disabled
道具。) Eg:(例如:)
<input type="text" :disabled="validated == 1">
Here is an example.(这是一个例子。)
var app = new Vue({ el: '#app', data: { disabled: 0, }, });
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> <button @click="disabled = (disabled + 1) % 2">Toggle Enable</button> <input type="text" :disabled="disabled == 1"> <pre>{{ $data }}</pre> </div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…