event.vue 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div>
  3. test - {{name}}
  4. <div>
  5. <Child @countChange="childListener" />
  6. <div>
  7. {{globalCount}}
  8. </div>
  9. </div>
  10. <div>
  11. 选择你的理想:(use v-model, :model doesn't work)
  12. <input type="checkbox" v-model="dreams" value="sleep"> sleeep
  13. <input type="checkbox" v-model="dreams" value="eat"> eeat
  14. </div>
  15. <div>
  16. 你有多高?
  17. <input type="radio" name="height" v-model="height" value="-1.7cm"> 低于一米七
  18. <input type="radio" name="height" v-model="height" value="+1.7cm"> 高于一米七
  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>