counter.js 362 B

1234567891011121314151617181920212223
  1. export default {
  2. template: `
  3. <button @click="handle_click">
  4. <strong>{{title}}: {{value}}</strong>
  5. </button>`,
  6. data() {
  7. return {
  8. value: 0,
  9. };
  10. },
  11. methods: {
  12. handle_click() {
  13. this.value += 1;
  14. this.$emit("change", this.value);
  15. },
  16. reset() {
  17. this.value = 0;
  18. },
  19. },
  20. props: {
  21. title: String,
  22. },
  23. };