这是我的表单文件,它包含 VUE 输入字段,我只想在选中该选项时才显示该字段Manually set new password。这是存在问题的最后一个字段。
var app = new Vue({
el: '#app',
data: {
password_options: 'keep'
}
computed: {
canShowThis() {
return ['auto', 'manual'].includes(this.password_options)
}
}
});
<script src="https://npmcdn.com/vue/dist/vue.js"></script>
<div class="field">
<label for="password" class="label">Password</label>
<p class="control">
<b-radio-group v-model="password_options">
<div class="field">
<b-radio name="password_options" value="keep" selected>
Do Not Change Password
</b-radio>
</div>
<div class="field">
<b-radio name="password_options" value="auto">
Auto Generate New Password
</b-radio>
</div>
<div class="field">
<b-radio name="password_options" value="manual">
Manually Set New Password
</b-radio>
<p class="control">
<input type="text" class="input m-b-10 m-t-10" name="password" id="password"
v-if="canShowThis" placeholder="Manually give a password to this user">
</p>
</div>
</b-radio-group>
</p>
</div>
<button class="button is-primary">
<i class="fa fa-refresh m-r-10"></i>Update User
</button>