event.vue 926 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. data() {
  26. return {
  27. name: "michael",
  28. globalCount: 0,
  29. dreams: [],
  30. height: ""
  31. };
  32. },
  33. methods: {
  34. childListener(v) {
  35. console.log(v);
  36. this.globalCount++;
  37. }
  38. },
  39. components: {
  40. Child
  41. }
  42. };
  43. </script>