tui-collapse.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Component({
  2. /**
  3. * 组件的属性列表
  4. */
  5. options: {
  6. multipleSlots: true
  7. },
  8. properties: {
  9. //collapse背景颜色
  10. bgColor: {
  11. type: String,
  12. value: 'none'
  13. },
  14. //collapse-head 背景颜色
  15. hdBgColor: {
  16. type: String,
  17. value: '#fff'
  18. },
  19. //collapse-body 背景颜色
  20. bdBgColor: {
  21. type: String,
  22. value: 'none'
  23. },
  24. //collapse-body实际高度 open时使用
  25. height: {
  26. type: String,
  27. value: 'auto'
  28. },
  29. //close时translateY ,当bd高度固定时,建议值为0
  30. translateY: {
  31. type: String,
  32. value: '-50%'
  33. },
  34. //索引
  35. index: {
  36. type: Number,
  37. value: 0
  38. },
  39. //当前索引,index==current时展开
  40. current: {
  41. type: Number,
  42. value: -1,
  43. observer(val) {
  44. this.updateCurrentChange();
  45. }
  46. },
  47. // 是否禁用
  48. disabled: {
  49. type: Boolean,
  50. value: false
  51. },
  52. //是否带箭头
  53. arrow: {
  54. type: Boolean,
  55. value: true
  56. },
  57. //箭头颜色
  58. arrowColor: {
  59. type: String,
  60. value: "#333"
  61. }
  62. },
  63. lifetimes: {
  64. ready: function() {
  65. this.updateCurrentChange()
  66. }
  67. },
  68. data: {
  69. isOpen: false
  70. },
  71. methods: {
  72. updateCurrentChange() {
  73. this.setData({
  74. isOpen: this.data.index == this.data.current
  75. })
  76. },
  77. handleClick() {
  78. if (this.data.disabled) return;
  79. this.triggerEvent("click", {
  80. index: Number(this.data.index)
  81. })
  82. }
  83. }
  84. })