event.vue 954 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div>
  3. test - {{ name }}
  4. <div>
  5. <Child @count-change="childListener" />
  6. <div>{{ globalCount }}</div>
  7. </div>
  8. <div>
  9. 选择你的理想:(use v-model, :model doesn't work)
  10. <input v-model="dreams" type="checkbox" value="sleep" /> sleeep
  11. <input v-model="dreams" type="checkbox" value="eat" /> eeat
  12. </div>
  13. <div>
  14. 你有多高?
  15. <input v-model="height" type="radio" name="height" value="-1.7cm" />
  16. 低于一米七
  17. <input v-model="height" type="radio" name="height" value="+1.7cm" />
  18. 高于一米七
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import Child from "./child";
  24. export default {
  25. name: "Event",
  26. components: {
  27. Child,
  28. },
  29. data() {
  30. return {
  31. name: "michael",
  32. globalCount: 0,
  33. dreams: [],
  34. height: "",
  35. };
  36. },
  37. methods: {
  38. childListener(v) {
  39. console.log(v);
  40. this.globalCount++;
  41. },
  42. },
  43. };
  44. </script>