Last active
September 7, 2024 00:54
-
-
Save JeffreyWay/ec2b23af4e10e6d0ce4b23e200d2c777 to your computer and use it in GitHub Desktop.
Learn Vue 3: Step By Step - Episode 2, Attribute Binding and Event Handling - https://laracasts.com/series/learn-vue-3-step-by-step/episodes/2
This file contains 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Episode 2: Attribute Binding and Basic Events</title> | |
<script src="https://unpkg.com/vue@3"></script> | |
<style> | |
html, body { | |
height: 100%; | |
} | |
body { | |
display: grid; | |
place-items: center; | |
} | |
.text-red { | |
color: red; | |
} | |
.text-green { | |
color: green; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app"> | |
<button | |
:class="active ? 'text-red' : 'text-green'" | |
@click="toggle" | |
>Click Me</button> | |
</div> | |
<script> | |
Vue.createApp({ | |
data() { | |
return { | |
active: false | |
}; | |
}, | |
methods: { | |
toggle() { | |
this.active = ! this.active; | |
} | |
} | |
}).mount('#app'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment