index.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Wux Weapp 3.11.0
  3. * 一套组件化、可复用、易扩展的微信小程序 UI 组件库
  4. * https://github.com/wux-weapp/wux-weapp#readme
  5. *
  6. * Copyright 2017-2024 skyvow
  7. *
  8. * Released under the MIT License
  9. *
  10. * Released on: 2024-3-21
  11. */
  12. import $wuxCountDown from './countdown/index'
  13. import $wuxCountUp from './countup/index'
  14. /**
  15. * 使用选择器选择组件实例节点,返回匹配到的第一个组件实例对象
  16. * @param {String} selector 节点选择器
  17. * @param {Object} ctx 页面栈或组件的实例,默认为当前页面栈实例
  18. */
  19. export const getCtx = (selector, ctx = getCurrentPages()[getCurrentPages().length - 1]) => {
  20. const componentCtx = ctx.selectComponent(selector)
  21. if (!componentCtx) {
  22. throw new Error('无法找到对应的组件,请按文档说明使用组件')
  23. }
  24. return componentCtx
  25. }
  26. const version = '3.11.0'
  27. const $wuxActionSheet = (selector = '#wux-actionsheet', ctx) => getCtx(selector, ctx)
  28. const $wuxBackdrop = (selector = '#wux-backdrop', ctx) => getCtx(selector, ctx)
  29. const $wuxApp = (selector = '#wux-app', ctx) => getCtx(selector, ctx)
  30. const $wuxDialog = (selector = '#wux-dialog', ctx) => getCtx(selector, ctx)
  31. const $wuxLoading = (selector = '#wux-loading', ctx) => getCtx(selector, ctx)
  32. const $wuxNotification = (selector = '#wux-notification', ctx) => getCtx(selector, ctx)
  33. const $wuxToast = (selector = '#wux-toast', ctx) => getCtx(selector, ctx)
  34. const $wuxToptips = (selector = '#wux-toptips', ctx) => getCtx(selector, ctx)
  35. const $wuxCalendar = (selector = '#wux-calendar', ctx) => getCtx(selector, ctx)
  36. const $wuxForm = (selector = '#wux-form', ctx) => getCtx(selector, ctx)
  37. const $wuxGallery = (selector = '#wux-gallery', ctx) => getCtx(selector, ctx)
  38. const $wuxIndex = (selector = '#wux-index', ctx) => getCtx(selector, ctx)
  39. const $wuxKeyBoard = (selector = '#wux-keyboard', ctx) => getCtx(selector, ctx)
  40. const $startWuxRefresher = (selector = '#wux-refresher', ctx) => getCtx(selector, ctx).triggerRefresh()
  41. const $stopWuxRefresher = (selector = '#wux-refresher', ctx) => getCtx(selector, ctx).finishPullToRefresh()
  42. const $stopWuxLoader = (selector = '#wux-refresher', ctx, isEnd) => getCtx(selector, ctx).finishLoadmore(isEnd)
  43. const $wuxSelect = (selector = '#wux-select', ctx) => getCtx(selector, ctx)
  44. export {
  45. version,
  46. $wuxCountDown,
  47. $wuxCountUp,
  48. $wuxActionSheet,
  49. $wuxBackdrop,
  50. $wuxApp,
  51. $wuxDialog,
  52. $wuxLoading,
  53. $wuxNotification,
  54. $wuxToast,
  55. $wuxToptips,
  56. $wuxCalendar,
  57. $wuxForm,
  58. $wuxGallery,
  59. $wuxIndex,
  60. $wuxKeyBoard,
  61. $startWuxRefresher,
  62. $stopWuxRefresher,
  63. $stopWuxLoader,
  64. $wuxSelect
  65. }