event.vue 953 B

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