Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --> Click event
- Onclick event
- 1. <template>
- 2. <button v-on:click="count++">Add 1</button>
- 3. <p>Count is: {{ count }}</p>
- 4. </template>
- 5. <script>
- 6. export default {
- 7. name: "Hello",
- 8. data() {
- 9. return {
- 10. count: 0
- 11. }
- 12. }
- 13. }
- 14. </script>
- --> Call a function onclick
- Call a function onclick
- 1. <template>
- 2. <button v-on:click="getAge()">GetAge</button>
- 3. </template>
- 4. <script>
- 5. export default {
- 6. name: "Hello",
- 7. methods: {
- 8. getAge() {
- 9. alert(26)
- 10. }
- 11. }
- 12. }
- 13. </script>
- --> Pass params with event
- 1. <template>
- 2. <button v-on:click="getAge(25)">GetAge</button>
- 3. </template>
- 4. <script>
- 5. export default {
- 6. name: "Hello",
- 7. methods: {
- 8. getAge(data) {
- 9. alert(data)
- 10. }
- 11. }
- 12. }
- 13. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement