Browse Source

feat: add more expose methods for `apiComponent` (#5958)

* 为ApiComponent组件添加getOptions和getValue导出方法。
pull/5960/head
Netfan 10 months ago
committed by GitHub
parent
commit
fcdc1a1602
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      docs/src/components/common-ui/vben-api-component.md
  2. 4
      packages/effects/common-ui/src/components/api-component/api-component.vue

2
docs/src/components/common-ui/vben-api-component.md

@ -169,3 +169,5 @@ function fetchApi(): Promise<Record<string, any>> {
| --- | --- | --- | --- |
| getComponentRef | 获取被包装的组件的实例 | ()=>T | >5.5.4 |
| updateParam | 设置接口请求参数(将与params属性合并) | (newParams: Record<string, any>)=>void | >5.5.4 |
| getOptions | 获取已加载的选项数据 | ()=>OptionsItem[] | >5.5.4 |
| getValue | 获取当前值 | ()=>any | >5.5.4 |

4
packages/effects/common-ui/src/components/api-component/api-component.vue

@ -242,6 +242,10 @@ function emitChange() {
}
const componentRef = ref();
defineExpose({
/** 获取options数据 */
getOptions: () => unref(getOptions),
/** 获取当前值 */
getValue: () => unref(modelValue),
/** 获取被包装的组件实例 */
getComponentRef: <T = any,>() => componentRef.value as T,
/** 更新Api参数 */

Loading…
Cancel
Save