Created
April 12, 2022 13:29
-
-
Save oxfordyang2016/9474468df3ff58ca74f1f6446b5abf6c to your computer and use it in GitHub Desktop.
Component basics
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="components-demo"> | |
<button-counter></button-counter> | |
</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
// Create a Vue application | |
const app = Vue.createApp({}) | |
// Define a new global component called button-counter | |
app.component('button-counter', { | |
data() { | |
return { | |
count: 0 | |
} | |
}, | |
template: ` | |
<button v-on:click="count++"> | |
You clicked me {{ count }} times. | |
</button>` | |
}) | |
app.mount('#components-demo') |
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
.demo { | |
font-family: sans-serif; | |
border: 1px solid #eee; | |
border-radius: 2px; | |
padding: 20px 30px; | |
margin-top: 1em; | |
margin-bottom: 40px; | |
user-select: none; | |
overflow-x: auto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment