Created
December 1, 2020 18:22
-
-
Save mcanv/6ad8a86fbdc5b17eecbdc3570da50027 to your computer and use it in GitHub Desktop.
AlpineJS Hello World
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>AlpineJS Hello World</title> | |
| </head> | |
| <body> | |
| <div x-data="app()"> | |
| <button x-on:click="toggleMessage()" x-text="messageShow ? 'Hide': 'Show'"></button> | |
| <h1 x-show="messageShow" x-text="message"></h1> | |
| </div> | |
| <script> | |
| function app() { | |
| return { | |
| message: 'Hello World', | |
| messageShow: true, | |
| toggleMessage() { | |
| this.messageShow = !this.messageShow | |
| } | |
| } | |
| } | |
| </script> | |
| <script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment