index.ts 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { ComponentWithComputed } from 'miniprogram-computed'
  2. // components/downselect/index.ts
  3. ComponentWithComputed({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. dateArr:Array,
  9. current: Object
  10. },
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. isShowDown:false
  16. },
  17. watch: {
  18. isShowDown: function (isShowDown) {
  19. this.triggerEvent('isShowDown',{isShowDown:isShowDown}, { bubbles: true, composed: true })
  20. },
  21. },
  22. /**
  23. * 组件的方法列表
  24. */
  25. methods: {
  26. onTab(){
  27. this.setData({
  28. isShowDown: !this.data.isShowDown
  29. })
  30. },
  31. tapItem(e:any){
  32. let {key} = e.target.dataset
  33. let item = this.data.dateArr.find((ii:any)=>ii.key == key)
  34. this.setData({
  35. current:item,
  36. isShowDown:false
  37. })
  38. this.triggerEvent('currentSelect',{current:this.data.current}, { bubbles: true, composed: true })
  39. },
  40. }
  41. })