uni-refresh.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <!-- #ifdef APP-NVUE -->
  3. <refresh :display="display" @refresh="onrefresh" @pullingdown="onpullingdown">
  4. <slot />
  5. </refresh>
  6. <!-- #endif -->
  7. <!-- #ifndef APP-NVUE -->
  8. <view ref="uni-refresh" class="uni-refresh" v-show="isShow">
  9. <slot />
  10. </view>
  11. <!-- #endif -->
  12. </template>
  13. <script>
  14. export default {
  15. name: 'UniRefresh',
  16. props: {
  17. display: {
  18. type: [String],
  19. default: "hide"
  20. }
  21. },
  22. data() {
  23. return {
  24. pulling: false
  25. }
  26. },
  27. computed: {
  28. isShow() {
  29. if (this.display === "show" || this.pulling === true) {
  30. return true;
  31. }
  32. return false;
  33. }
  34. },
  35. created() {},
  36. methods: {
  37. onchange(value) {
  38. this.pulling = value;
  39. },
  40. onrefresh(e) {
  41. this.$emit("refresh", e);
  42. },
  43. onpullingdown(e) {
  44. // #ifdef APP-NVUE
  45. this.$emit("pullingdown", e);
  46. // #endif
  47. // #ifndef APP-NVUE
  48. var detail = {
  49. viewHeight: 90,
  50. pullingDistance: e.height
  51. }
  52. this.$emit("pullingdown", detail);
  53. // #endif
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped>
  59. .uni-refresh {
  60. height: 0;
  61. overflow: hidden;
  62. }
  63. </style>