Menu
×
×
Correct!
Exercise:Use the shorthand of a Vue directive so that the light bulb turns on and off when the button is clicked.
<div id="app">
<div id="lightDiv">
<div v-show="lightOn"></div>
<img src="img_lightBulb.svg">
</div>
<button @click=" lightOn =! lightOn ">Switch light</button>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
const app = Vue.createApp({
data() {
return {
lightOn: false
}
}
})
app.mount('#app')
</script>
Not CorrectClick here to try again. Correct!Next ❯<div id="app"> <div id="lightDiv"> <div v-show="lightOn"></div> <img src="img_lightBulb.svg"> </div> <button=" lightOn =! lightOn ">Switch light</button> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { lightOn: false } } }) app.mount('#app') </script> |