Created
October 28, 2021 19:33
-
-
Save danyn/aff048b9efc3b08493a2cb2a62551f1a to your computer and use it in GitHub Desktop.
Watcher Exercise Problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<div> | |
<button @click="getTaco"> | |
Click me to order a taco | |
</button> | |
<h2>{{order}}</h2> | |
<p v-if="orderStatus">{{ orderStatus }}</p> | |
<p></p> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = { | |
data() { | |
return { | |
orderStatus: 'Where is my taco...', | |
order: '', | |
orderSubmitted: null | |
} | |
}, | |
methods: { | |
getTaco() { | |
this.order = 'Getting Taco.' | |
this.orderStatus = '' | |
} | |
}, | |
watch: { | |
orderStatus(newVal, oldVal) { | |
setTimeout(()=>this.order = "🌮", 2000); | |
} | |
} | |
} | |
Vue.createApp(App).mount('#app') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/vue@next"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#app { | |
margin: 30px; | |
} | |
button { | |
display: inline-block; | |
border: none; | |
padding: 0.75rem 1.5rem; | |
margin: 0; | |
text-decoration: none; | |
background: teal; | |
border-radius: 4px; | |
color: #ffffff; | |
font-family: sans-serif; | |
font-size: 1rem; | |
cursor: pointer; | |
text-align: center; | |
transition: background 250ms ease-in-out, transform 150ms ease; | |
-webkit-appearance: none; | |
-moz-appearance: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment