const.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const emits = ['input', 'change', 'click', 'rendered', 'scroll']
  2. let valueField = "value" // v-model绑定属性名
  3. // #ifdef VUE3
  4. emits.splice(0, 1, 'update:modelValue')
  5. valueField = "modelValue"
  6. // #endif
  7. const props = {
  8. color: String, //标签主题色, 默认值为"#0022AB"
  9. background: String, //标签栏背景色,默认值为"#fff"
  10. lineWidth: [Number, String], //底部条宽度,默认单位为px, 默认值为20px
  11. lineHeight: [Number, String], //底部条高度,默认单位为px,默认值为3px
  12. titleActiveColor: String, //标题选中态颜色
  13. titleInactiveColor: String, //标题默认态颜色
  14. // 标签栏样式
  15. wrapStyle: {
  16. type: [Object, null],
  17. default: () => {}
  18. },
  19. // 动画时间,单位秒
  20. duration: {
  21. type: [Number, String],
  22. default: 0.3,
  23. },
  24. // 样式风格类型,可选值为 text、card、button、line-button
  25. type: {
  26. type: String,
  27. default: "line"
  28. },
  29. // 标签页数据,支持字符串类型与对象类型的数组结构
  30. // 对象类型需符合{label:'标签1',slot:'slotName'}这样的格式,slot为自定义的标签内容插槽名,否则插槽名默认为"pane"+tab下标的命名
  31. tabs: {
  32. type: Array,
  33. default: () => []
  34. },
  35. // 是否省略过长的标题文字
  36. ellipsis: {
  37. type: Boolean,
  38. default: true,
  39. },
  40. // 标签栏滚动时当前标签居中
  41. scrollToCenter: {
  42. type: Boolean,
  43. default: true,
  44. },
  45. // 标签栏的滚动阈值(仅在ellipsis="false"且type不为"card"下时有效),标签数量超过阈值且总宽度超过标签栏宽度时开始横向滚动(切换时会自动将当前标签居中)
  46. scrollThreshold: {
  47. type: [Number, String],
  48. default: 5
  49. },
  50. // 是否开启延迟渲染(首次切换到标签时才触发内容渲染)
  51. isLazyRender: {
  52. type: Boolean,
  53. default: true,
  54. },
  55. // 是否开启切换标签内容时的转场动画
  56. animated: {
  57. type: Boolean,
  58. default: false
  59. },
  60. // 在点击标签标题时,页面是否会滚动回到顶部
  61. tabClickScrollTop: {
  62. type: Boolean,
  63. default: false
  64. },
  65. // 对于只想使用标题栏功能而不关注标签内容,可使用该属性关闭标签内容的渲染
  66. noRenderConent: Boolean,
  67. // 滚动导航: 通过 scrollspy 属性可以开启滚动导航模式,该模式下,内容将会平铺展示。
  68. scrollspy: Boolean,
  69. // 切换标签前的回调函数,返回 false 可阻止切换,支持返回 Promise
  70. beforeChange: Function,
  71. // 滑动切换是否使用swiper组件实现
  72. swiper: {
  73. type: Boolean,
  74. default: false,
  75. },
  76. // 是否开启手势滑动切换
  77. swipeable: {
  78. type: Boolean,
  79. default: false,
  80. },
  81. // 是否开启标签内容的拖动动画(该属性依赖于swipeable、is-lazy-render的开启;该属性开启时考虑给包裹内容的容器增加一个min-height,因为开启该属性后,其他未显示出来的标签内容会沿用当前显示的高度,拖动切换后由于高度不一致会有回弹)
  82. swipeAnimated: {
  83. type: Boolean,
  84. default: false,
  85. },
  86. // 滑动切换的滑动距离阈值,手指滑动页面触发切换的阈值,单位为px,表示横向滑动整个可视区域的多少px时才切换标签内容
  87. swipeThreshold: {
  88. type: [Number, String],
  89. default: 50,
  90. },
  91. // 保证组件的可见性,主要用于处理选中标签的底部线条位置
  92. visible: {
  93. type: Boolean,
  94. default: true
  95. },
  96. // 标签页是否滚动吸顶
  97. fixed: Boolean,
  98. // 滚动吸顶下与顶部的最小距离,默认 px
  99. offsetTop: {
  100. type: Number,
  101. default: 0
  102. },
  103. // 滚动吸顶/粘性布局下,标签栏的z-index值
  104. zIndex: {
  105. type: Number,
  106. default: 99
  107. },
  108. // 是否使用粘性定位布局
  109. sticky: Boolean,
  110. // 粘性布局的判断阈值
  111. stickyThreshold: {
  112. type: Number,
  113. default: 0
  114. },
  115. }
  116. // v-model绑定属性,绑定当前选中标签的标识符(标签的下标)
  117. props[valueField] = {
  118. type: Number,
  119. default: -1
  120. }
  121. export {
  122. emits,
  123. props,
  124. valueField
  125. }