提供正确的代码,以便在屏幕上显示“isImportant”计算属性。
<div id="app"> <form> <p> 重要项目? <label> <input type="checkbox" v-model="chbxVal"> @(17) </label> </p> </form> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { chbxVal: false } }, @(8): { isImportant() { if(this.chbxVal){ return 'yes' } else { return 'no' } } } }) app.mount('#app') </script>
<div id="app"> <form> <p> 重要项目? <label> <input type="checkbox" v-model="chbxVal"> {{ isImportant }} </label> </p> </form> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { chbxVal: false } }, computed: { isImportant() { if(this.chbxVal){ return 'yes' } else { return 'no' } } } }) app.mount('#app') </script>
<div id="app"> <form> <p> 重要项目? <label> <input type="checkbox" v-model="chbxVal"> {{isImportant}} </label> </p> </form> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { chbxVal: false } }, computed: { isImportant() { if(this.chbxVal){ return 'yes' } else { return 'no' } } } }) app.mount('#app') </script>