index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { Image, PullRefresh } from 'vant';
  2. import { defineComponent, reactive, watch } from 'vue';
  3. import styles from './index.module.less';
  4. import { Vue3Lottie } from 'vue3-lottie';
  5. import AstronautJSON from './datas/data.json';
  6. import 'vue3-lottie/dist/style.css';
  7. import loading from './loading.gif';
  8. import loadingJSon from './loading.json';
  9. export default defineComponent({
  10. name: 'm-full-refresh',
  11. props: {
  12. title: String,
  13. modelValue: {
  14. type: Boolean,
  15. default: false
  16. }
  17. },
  18. emits: ['refresh', 'update:modelValue'],
  19. setup(props, { emit, slots }) {
  20. const state = reactive({
  21. fullState: false
  22. });
  23. watch(
  24. () => props.modelValue,
  25. (val: boolean) => {
  26. state.fullState = val;
  27. }
  28. );
  29. watch(
  30. () => state.fullState,
  31. (val: boolean) => {
  32. emit('update:modelValue', val);
  33. }
  34. );
  35. return () => (
  36. <PullRefresh
  37. v-model:modelValue={state.fullState}
  38. onRefresh={() => emit('refresh')}
  39. loadingText=" "
  40. class={styles.pullRefresh}>
  41. {{
  42. // loading: () => (
  43. // <div>
  44. // {
  45. // // <Image src={loadingJSon.loading} class={styles.loading} />
  46. // <Vue3Lottie
  47. // class={styles.animateWrap}
  48. // animationData={AstronautJSON}></Vue3Lottie>
  49. // }
  50. // </div>
  51. // ),
  52. // pulling: () => (
  53. // <div>
  54. // {
  55. // // <Image src={loading} class={styles.loading} />
  56. // <Vue3Lottie
  57. // class={styles.animateWrap}
  58. // animationData={AstronautJSON}></Vue3Lottie>
  59. // }
  60. // </div>
  61. // ),
  62. // loosing: () => (
  63. // <div>
  64. // {
  65. // // <Image src={loading} class={styles.loading} />
  66. // <Vue3Lottie
  67. // class={styles.animateWrap}
  68. // animationData={AstronautJSON}></Vue3Lottie>
  69. // }
  70. // </div>
  71. // ),
  72. default: () => <> {slots.default && slots.default()}</>
  73. }}
  74. </PullRefresh>
  75. );
  76. }
  77. });