index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import $wuxCountDown from './countdown/index'
  2. import $wuxCountUp from './countup/index'
  3. /**
  4. * 使用选择器选择组件实例节点,返回匹配到的第一个组件实例对象
  5. * @param {String} selector 节点选择器
  6. * @param {Object} ctx 页面栈或组件的实例,默认为当前页面栈实例
  7. */
  8. const getCtx = (selector, ctx = getCurrentPages()[getCurrentPages().length - 1]) => {
  9. const componentCtx = ctx.selectComponent(selector)
  10. if (!componentCtx) {
  11. throw new Error('无法找到对应的组件,请按文档说明使用组件')
  12. }
  13. return componentCtx
  14. }
  15. const $wuxActionSheet = (selector = '#wux-actionsheet', ctx) => getCtx(selector, ctx)
  16. const $wuxBackdrop = (selector = '#wux-backdrop', ctx) => getCtx(selector, ctx)
  17. const $wuxToast = (selector = '#wux-toast', ctx) => getCtx(selector, ctx)
  18. const $wuxLoading = (selector = '#wux-loading', ctx) => getCtx(selector, ctx)
  19. const $wuxDialog = (selector = '#wux-dialog', ctx) => getCtx(selector, ctx)
  20. const $wuxToptips = (selector = '#wux-toptips', ctx) => getCtx(selector, ctx)
  21. const $wuxGallery = (selector = '#wux-gallery', ctx) => getCtx(selector, ctx)
  22. const $wuxNotification = (selector = '#wux-notification', ctx) => getCtx(selector, ctx)
  23. const $wuxKeyBoard = (selector = '#wux-keyboard', ctx) => getCtx(selector, ctx)
  24. const $wuxSelect = (selector = '#wux-select', ctx) => getCtx(selector, ctx)
  25. const $wuxCalendar = (selector = '#wux-calendar', ctx) => getCtx(selector, ctx)
  26. const $stopWuxRefresher = (selector = '#wux-refresher', ctx) => getCtx(selector, ctx).finishPullToRefresh()
  27. const $stopWuxLoader = (selector = '#wux-refresher', ctx, isEnd) => getCtx(selector, ctx).finishLoadmore(isEnd)
  28. export {
  29. $wuxActionSheet,
  30. $wuxBackdrop,
  31. $wuxToast,
  32. $wuxLoading,
  33. $wuxDialog,
  34. $wuxToptips,
  35. $wuxGallery,
  36. $wuxNotification,
  37. $wuxKeyBoard,
  38. $wuxSelect,
  39. $wuxCalendar,
  40. $stopWuxRefresher,
  41. $stopWuxLoader,
  42. $wuxCountDown,
  43. $wuxCountUp,
  44. }