P粉1627736262023-08-30 17:25:33
您可以在複選框上設定 v-model
並使用該值停用下拉式選單。
const app = Vue.createApp({ data() { return { checkBox: false } } }) app.mount('#app')
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <div id="app"> <input type="checkbox" v-model="checkBox" /> <p>checkBox: {{checkBox}}</p> <select :disabled="!checkBox" name="pets" id="pet-select"> <option value="">--Please choose an option--</option> <option value="dog">Dog</option> <option value="cat">Cat</option> <option value="hamster">Hamster</option> <option value="parrot">Parrot</option> <option value="spider">Spider</option> <option value="goldfish">Goldfish</option> </select> </div>