list.wpy 885 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <style lang="less">
  2. .mylist:odd {
  3. color: red;
  4. }
  5. .mylist:even {
  6. color: green;
  7. }
  8. </style>
  9. <template>
  10. <div class="list">
  11. This component is not used. because list is an aliasField in package.json
  12. </div>
  13. </template>
  14. <script>
  15. import wepy from '@wepy/core'
  16. wepy.component({
  17. data: {
  18. list: [
  19. {
  20. id: '0',
  21. title: 'loading'
  22. }
  23. ]
  24. },
  25. events: {
  26. 'index-broadcast': (...args) => {
  27. let $event = args[args.length - 1]
  28. console.log(`${this.$name} receive ${$event.name} from ${$event.source.name}`)
  29. }
  30. },
  31. methods: {
  32. tap () {
  33. // this.num = this.num + 1
  34. console.log(this.$name + ' tap')
  35. },
  36. add () {
  37. let len = this.list.length
  38. this.list.push({id: len + 1, title: 'title_' + len})
  39. }
  40. }
  41. onLoad () {
  42. }
  43. });
  44. </script>