提供正确的代码,以便“isImportant”计算属性显示在屏幕上。
<div id="app">
<form>
<p>
Important item?
<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>
Important item?
<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>
Important item?
<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>