mini-stores icon indicating copy to clipboard operation
mini-stores copied to clipboard

建议状态的绑定可以再简化下,可以参考下alova的vue options写法

Open 1075488066 opened this issue 2 years ago • 0 comments

  import { useRequest } from 'alova';
  import { mapAlovaHook } from '@alova/vue-options';
  import { getData } from './api';

  export default {
    // mapAlovaHook将返回mixins数组,use hook的用法与之前一致
    mixins: mapAlovaHook(function (vm) {
      // 可以通过this或vm来访问组件实例
      // 使用this时,此回调函数不能为箭头函数
      console.log(this, vm);
      return {
        todoRequest: useRequest(getData)
      };
    }),
    created() {
      this.todoRequest.loading;
      this.todoRequest$send();
      this.todoRequest$onSuccess(event => {
        event.data.match;
        event.sendArgs.copyWithin;
      });
      this.todoRequest$onSuccess(event => {
        console.log('success', event);
      });
      this.todoRequest$onError(event => {
        console.log('error', event);
      });
    },
    mounted() {
      this.todoRequest$onComplete(event => {
        console.log('complete', event);
      });
    }
  };

1075488066 avatar Feb 24 '24 09:02 1075488066