App.vue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<template> <div> <vue-poll v-bind="options" @addvote="addVote" /> </div> </template> <script> import VuePoll from "vue-poll"; export default { data() { return { options: { question: "What's your favourite <strong>JS</strong> framework?", answers: [ { value: 1, text: "Vue", votes: 53 }, { value: 2, text: "React", votes: 35 }, { value: 3, text: "Angular", votes: 30 }, { value: 4, text: "Other", votes: 10 }, ], }, }; }, components: { VuePoll, }, methods: { addVote(obj) { console.log("You voted " + obj.value + "!"); }, }, }; </script> |