Skip to content

Commit

Permalink
feat(api-select): auto refetch after params changed
Browse files Browse the repository at this point in the history
ApiSelect 组件在params改变后自动重新获取远程数据
  • Loading branch information
mynetfan committed Jun 5, 2021
1 parent 4805ca2 commit 50207ad
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/Form/src/components/ApiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</Select>
</template>
<script lang="ts">
import { defineComponent, PropType, ref, watchEffect, computed, unref } from 'vue';
import { defineComponent, PropType, ref, watchEffect, computed, unref, watch } from 'vue';
import { Select } from 'ant-design-vue';
import { isFunction } from '/@/utils/is';
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
Expand Down Expand Up @@ -93,6 +93,14 @@
props.immediate && fetch();
});
watch(
() => props.params,
() => {
!unref(isFirstLoad) && fetch();
},
{ deep: true }
);
async function fetch() {
const api = props.api;
if (!api || !isFunction(api)) return;
Expand Down

0 comments on commit 50207ad

Please sign in to comment.