group.wpy 895 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <style type="less">
  2. .group {}
  3. </style>
  4. <template>
  5. <div class="group">
  6. <span class="id">{{grouplist.id}}. </span>
  7. <span class="name" @tap="tap">{{grouplist.name}}</span>
  8. <div>
  9. <div v-for="item in grouplist.list">
  10. <groupitem :gitem="item"></groupitem>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import wepy from '@wepy/core';
  17. //import GroupItem from './groupitem'
  18. wepy.component({
  19. props: {
  20. grouplist: {},
  21. index: {}
  22. },
  23. methods: {
  24. tap () {
  25. this.grouplist.name = `Parent Random(${Math.random()})`
  26. let groups = this.$parent.$children.filter(com => com.$is === 'components/group');
  27. let index = groups.indexOf(this);
  28. console.log(`Clicked Group ${index}, ID is ${this.grouplist.id}`)
  29. }
  30. }
  31. });
  32. </script>
  33. <config>
  34. {
  35. usingComponents: {
  36. 'groupitem': './groupitem'
  37. }
  38. }
  39. </config>