1
0

counter.js 562 B

12345678910111213141516171819202122232425
  1. // NOTE: Make sure to reload the browser with cache disabled after making changes to this file.
  2. export default {
  3. template: `
  4. <button @click="handle_click" :style="{ background: value > 0 ? '#bf8' : '#eee', padding: '8px 16px', borderRadius: '4px' }">
  5. <strong>{{title}}: {{value}}</strong>
  6. </button>
  7. `,
  8. props: {
  9. title: String,
  10. },
  11. data() {
  12. return {
  13. value: 0,
  14. };
  15. },
  16. methods: {
  17. handle_click() {
  18. this.value += 1;
  19. this.$emit("change", this.value);
  20. },
  21. reset() {
  22. this.value = 0;
  23. },
  24. },
  25. };