提交 50207ad7 作者: 无木

feat(api-select): auto refetch after params changed

ApiSelect 组件在params改变后自动重新获取远程数据
上级 4805ca26
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</Select> </Select>
</template> </template>
<script lang="ts"> <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 { Select } from 'ant-design-vue';
import { isFunction } from '/@/utils/is'; import { isFunction } from '/@/utils/is';
import { useRuleFormItem } from '/@/hooks/component/useFormItem'; import { useRuleFormItem } from '/@/hooks/component/useFormItem';
...@@ -93,6 +93,14 @@ ...@@ -93,6 +93,14 @@
props.immediate && fetch(); props.immediate && fetch();
}); });
watch(
() => props.params,
() => {
!unref(isFirstLoad) && fetch();
},
{ deep: true }
);
async function fetch() { async function fetch() {
const api = props.api; const api = props.api;
if (!api || !isFunction(api)) return; if (!api || !isFunction(api)) return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论